Interpreting return code of recv() socket api

Discussion in 'C++' started by yaniv135, Aug 4, 2012.

  1. yaniv135

    yaniv135 New Member

    Joined:
    Aug 4, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi.

    I have a situation where client waits on recv() on a socket in one thread. And , I am monitoring the same socket for timeout on another thread. When the timeout occurs , the second thread drops the socket.
    As a result the first thread waiting on recv() gets a return code 0 (no bytes received ) with no error number set.
    Now there is another case where recv() at client returns with 0 before the timeout , which is , when there is an issue with the server and it terminates the connection without sending any data.

    Is the above behaviour of recv() in both cases correct ? If yes , is there a way at the client to differentiate between the two cases ? In both cases recv() returns with 0 and no error number.

    Please let me know.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice