none
TCP/IP client problems

    Question

  • Hello to everyone!

    I'm working on a TCP/IP communication for communicating between industrial robot controller and regular PC, so basically I'm working on a client which will be the part of a program running on a PC.

    I did some research and find the event driven asynchronous client example on Daniweb (https://www.daniweb.com/…/user-friendly-asynchronous-event-…). So my client is based on that class with minor changes, like no receive timeout, because if the machine is idle I will not get any messages for a long time.
    I tested my client against SocketTest 3.0. At normal conditions everything works fine, but because the software will be used in industrial environments the possible failures needs to be handled correctly and that's what I was excepting from the code.

    So I did some further testing...

    1. Close server when client is still open and connected.
    After a short period of time the ConectionStateChanged event is triggered. The actual event is triggered because of error detected in function cbDataReceived. So is it expected that the absence of the server is detected in the receive part of the code?

    2. Disconnect the ethernet cable.
    There is actually no reaction to that, even the send command goes through with no problem. So if I press the send test button n times and send x data while cable still unplugged nothing will happen. Then if I plug the cable back nothing will happen until I press the send button again. Then the server will receive x data, n+1 times.

    I'm apologizing for my possible bad terminology. My profession is not a computer engineering. I had to know how things works in TCP/IP, but that was a few years ago and it was mostly based on theoretical aspects.

    I'm open for any suggestions. Is the Daniweb class solution the right way to do it? How to handle all the problems that can occur with a connection the right way? If there are any libraries available (even the commercial ones) that will help solve me the problems feel free to write them down.

    Thank you very much for help in advance.


    Saturday, April 15, 2017 9:41 AM

All replies

  • I have used the Daniweb code as the basis for my own TCP Listeners ... Daniweb was a good start, but I ended up needing to tweak it quite a bit. I'm not able to look at my code right now, but I'll try to get to it a few hours from now and see if I can give you any pointers. Unfortunately, I'm not sure how much of the actual code I can give you, and I won't know how much until I look at it. Maybe just a few pointers for you might be enough.

    Question ... you mentioned testing against SocketTest 3.0 ... what is that? It sounds like it might be useful ...

     

    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Saturday, April 15, 2017 4:32 PM
    Moderator
  • I'm looking forward for your help, thank you very much in advance.

    SocketTest 3.0 is a program for socket testing written in Java. You can find more about it here. I like it mainly because it can also act as a server and the user interface is very intuitive.

    Saturday, April 15, 2017 7:17 PM
  • I have quite a few changes to the DaniWeb EventDrivenTCPClient code. Plus, it's not used directly, I have another TcpListener class that handles the events fired in the EventDrivenTCPClient class. So, I'm not going to really be able to post any of it here. Send me an email (go to my blog and click on my Profile for an email address to use) ...

    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Saturday, April 15, 2017 8:16 PM
    Moderator
  • Hi Primoz,

    I know this thread is very old, but in case others were interested, I thought that I should post an update here. I've already sent you an email.

    I just finished re-working my Event-Driven TCP Client example code and posted it to my blog yesterday:

    http://geek-goddess-bonnie.blogspot.com/2018/12/event-driven-tcp.html

    Have fun!  =0)

    ~~Bonnie


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Saturday, December 29, 2018 5:25 PM
    Moderator