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

    delay in receiving "WSAECONNRESET" for send

    Hello,
    Not sue if this is correct thraed. but could any one help me?

    What i am trying is, to detect the Connection reset by peer in order to hanlde it correctly.
    What i observed is that "send" socket call is not returnuing "WSAECONNRESET" when the server is shutdown. I do get the error "WSAECONNRESET" after perfroming multiple sends. till then it is returning No error. Could any one tell me how to get the error first time?
    i am using windows sockets.


    Regards
    Vin.

  2. #2
    Join Date
    Feb 2005
    Posts
    2,160

    Re: delay in receiving "WSAECONNRESET" for send

    Sounds like the peer is just closing the socket and NOT shutting the socket down first. Is the peer your program, or some other client?

    See MSDN for more info:

    http://msdn.microsoft.com/en-us/libr...81(VS.85).aspx

  3. #3
    Join Date
    Sep 2009
    Posts
    2

    Re: delay in receiving "WSAECONNRESET" for send

    Peer is another program and i cannot access the code for t.
    Basically , i am working on client to send data to the server. the server is running on other machine. When i switch off the server pc , and and send some data from client, i am expecting the send should fail and return "WSAECONNRESET". but this is not happenning and i am getting "no error" for two or three times (3 sends) and then i am getting 'WSAECONNRESET".

  4. #4
    Join Date
    Feb 2005
    Posts
    2,160

    Re: delay in receiving "WSAECONNRESET" for send

    Well, if the server simply closes the socket, then the client doesn't know about it until its sends fail after a certain timeout. If the server calls a shutdown, the server basically tells the client it is closing the socket first so the client can handle it gracefully.

    You could set the wait timeout on your sending socket to a much lower value. If you are (as it sounds) working on a local network, then you can set your socket timeout really low so that send failures due to socket closure by the server will fail rather quickly and you'll get your send errors sooner, avoiding unnecessary waiting. There are a couple of ways to do this: my preferred method is to use select(),but there's setsockopt() with SO_RCVTIMEO or SO_SNDTIMEO.

Tags for this Thread

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