Re: send() returns error even though data is sent, TCP connection still alive



In article <1170269163.22436.71.camel@xxxxxxxxxxxxx>,
Jeff Davis <freebsd@xxxxxxxxxxx> wrote:

You should see something like "write failed: host is down" and the
session will terminate. Of course, when ssh exits, the TCP connection
closes. The only way to see that it's still open and active is by
writing (or using) an application that ignores EHOSTDOWN errors from
write().

I agree that it's a bug. The only time write() on a stream socket
should return the asynchronous error[1] is when the connection has
been (or is in the process of being) torn down as a result of a
subsequent timeout. POSIX says "may fail" for these errors write()
and send() on sockets

-GAWollman

[1] There are two kinds of error returns in the socket model:
synchronous errors, like synchronous signals, are attributed to the
result of a specific system call, detected prior to syscall return,
and usually represent programming or user error (e.g., attempting to
connect() on an fd that is not a socket). Asynchronous errors are
detected asynchronously, and merely posted to the socket without being
delivered; they may be delivered on the next socket operation. See
XSH 2.10.10, "Pending Error".

_______________________________________________
freebsd-stable@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: send() returns error even though data is sent, TCP connection still alive
    ... Of course, when ssh exits, the TCP connection ... There are two kinds of error returns in the socket model: ... synchronous errors, like synchronous signals, are attributed to the ... result of a specific system call, detected prior to syscall return, ...
    (freebsd-net)
  • Re: Blocking receive and close
    ... TCP does this precisely to avoid ... the socket is destroyed immediately. ... The TCP connection hangs ... But just before you enter the recv function, ...
    (comp.programming.threads)
  • Fatal trap 12 in binding V6 socket in FreeBSD 5.1-p2
    ... Has anyone else seen that in the FreeBSD 5.1-p2 if one is binding to a socket ... that has earliear been closed but the tcp connection is still in time wait ... page fault while in kernel mode ...
    (freebsd-net)
  • win32 socket, "Operation not supported"
    ... I have written an app which opens a TCP connection to a server and uses a protocol to communicate with it. ... available on a read socket, a full packet is read in a blocking fashion from the socket. ... The server side periodically sends updates on the state of the molecular dynamics engine. ...
    (comp.lang.python)
  • Re: win32 socket, "Operation not supported"
    ... protocol to communicate with it. ... > The protocol is very simple: both ends of the TCP connection can send ... blocking fashion from the socket. ... When I re-code the app in C, ...
    (comp.lang.python)