Re: Recv(), determining connection closed or broken

From: Umpa (_at_umpaumpalala.com)
Date: 05/18/04

  • Next message: Andrei Voropaev: "Re: Recv(), determining connection closed or broken"
    Date: Tue, 18 May 2004 10:25:12 +0200
    
    

    > If your side knows that the other side closed the connection normally,
    > 'recv' will return zero. If your side knows that an error has occured
    > (either locally or on the other side), 'recv' will return '-1' and 'errno'
    > will tell you want happened.
    >
    Here are errnos matched to recv():

    EBADF
    The argument s is an invalid descriptor.

    ECONNREFUSED
    A remote host refused to allow the network connection
    (typically because it is not running the requested service).

    ENOTCONN
    The socket is associated with a connection-oriented protocol
    and has not been connected (see connect(2) and accept(2)).

    ENOTSOCK
    The argument s does not refer to a socket.

    EAGAIN
    The socket is marked non-blocking and the receive operation would
    block, or a receive timeout had been set and the timeout expired before
    data was received.

    EINTR
    The receive was interrupted by delivery of a signal before any
    data were available.

    EFAULT
    The receive buffer pointer(s) point outside the process's address space.

    EINVAL
    Invalid argument passed.

    Please, do tell me what errno is set to when connection
    is broken during receiving ? Personally, I can`t see any.

    How about this:
    http://groups.google.pl/groups?q=recv+connection+broken&hl=pl&lr=&ie=UTF-8&s
    elm=3dcb2b2b%241_3%40corp.newsgroups.com&rnum=5

    Umpa.


  • Next message: Andrei Voropaev: "Re: Recv(), determining connection closed or broken"

    Relevant Pages

    • Re: closing ASyncSocket
      ... I reread the help for the ShutDown() call. ... not close the socket, and resources attached to the socket will not be freed ... What if I want to Closethe connection to return resources. ... receiving side after I received the last data. ...
      (microsoft.public.vc.mfc)
    • Re: Handling multiple connections
      ... each time select says the socket has more data. ... All data being sent by clients are prepended with a header that indicates ... received and thus delays receiving on the other readable sockets. ... When the client closes the connection, ...
      (microsoft.public.win32.programmer.networks)
    • Re: How can I tell when a remote TCP connection is closed?
      ... Recv only returns zero if the peer has ... to write to the socket and I get an broken pipe error. ... >I have a client with a TCP connection to a server. ... >need the code to be portable), is there a way that I can tell if the remote ...
      (microsoft.public.win32.programmer.networks)
    • Re: Non-blocking sockets
      ... the request and receiving the response. ... but reador recv() returns before any data is read, ... closing a connection ... temporarily unavailable) and not receiving any data. ...
      (comp.unix.programmer)
    • Re: RAS connection and Socket status
      ... You don't need a timer to check the current RAS status. ... recv) to ensure that status messages can be processed. ... RasGetConnectStatus to check it during the connection process ...
      (microsoft.public.pocketpc.developer)