Marc Lehmann wrote: >> The problem that I have is that I cannot seem to figure out the "right" >> way to close the socket at this point. > > the correct solution is to use a protocol with handshake.
Can you explain in more detail what you mean by this? I am already using a protocol with handshake, the message I am sending is the last goodbye. Trouble is the other side doesn't see they last goodbye, they just see connection reset by peer. >> as yet unsent. Because the write() is non blocking, the close is issued >> too early. Fair enough, this is the wrong way to do it. > > yes, close does not dump the data, regardless of whether write is blocking or > not. the kernel also buffers, regardless of whether the write is blocking or > not. > > blocking vs. non-blocking is not the issue, the behaviour is exactly the > same. That contradicts this: http://www.gnu.org/s/libc/manual/html_node/Closing-a-Socket.html#Closing-a-Socket Specifically the bit that says "Stop trying to transmit data from this socket. Discard any data waiting to be sent.". I am seeing data waiting to be sent being discarded, thus the original question. >> Does anyone know the right way to do this? > > yes, wait for an acknowledgement from the other side. tcp requires this, > regardless of blocking mode. How, using libev, do I wait for an acknowledgment from the other side? I can get an event saying "ready to write", but I cannot find an event that says "ready to close". Can you confirm? Regards, Graham --
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________ libev mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
