CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2009
    Posts
    1

    Help!: Problem with TCP connection to server after client crush/incorrect exit

    I'm supposed to connect to embedded server through TCP sockets (custom protocol).

    Just for sanity check, I've done sample which do following steps:

    1. TCP Connect (IPaddress, port);
    2. Send Test IP packet (server init command);
    3. Receive Responce;
    --> 4. TCP Close.

    This sequence works without glitch (yet).

    Problem:
    If client exits just one time without 4th step (TCP Close), then:
    1. Next time it goes through steps 1-2 and on 3 never get any responce from server.
    2. After that if I restart client, it breaks just on step 1 with "server actively refused connection". And MAINTAINs to refuse connections on that (address,port) for very long time >6hrs . Besides, http connection to same address (from brouser) is ok.


    Can anybody shed some light on the situation ? Isn't server supposed to handle that kind of situations ?

  2. #2
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    47

    Re: Help!: Problem with TCP connection to server after client crush/incorrect exit

    Quote Originally Posted by zubaziga View Post
    I'm supposed to connect to embedded server through TCP sockets (custom protocol).

    Just for sanity check, I've done sample which do following steps:

    1. TCP Connect (IPaddress, port);
    2. Send Test IP packet (server init command);
    3. Receive Responce;
    --> 4. TCP Close.

    This sequence works without glitch (yet).

    Problem:
    If client exits just one time without 4th step (TCP Close), then:
    1. Next time it goes through steps 1-2 and on 3 never get any responce from server.
    2. After that if I restart client, it breaks just on step 1 with "server actively refused connection". And MAINTAINs to refuse connections on that (address,port) for very long time >6hrs . Besides, http connection to same address (from brouser) is ok.


    Can anybody shed some light on the situation ? Isn't server supposed to handle that kind of situations ?
    Question: what if you restart the embedded server? Will it recover?

    My guess is that the server has timeout issue. It may wait for TCP close for a long time, i.e. 6 hours. Are you developing the embedded server firmware? If you are, you should check the timeout in the server.

    The fact that the web browser can connect to the embedded server, it means that the server does not hang. It can still do some calculation, it's just your particular module that doesn't work.

    Another question: does the server allow multiple connection? Can you connect two clients to the embedded server (not the web server) concurrently?
    Xander Tan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured