Ok, so figured out a way to do this and it seems clean and works with the select based backend but not the iocp based backend. Basically I just set the watermark for write to 1 and 0 and set a flag for "shutting down write". When I get the write callback at this point, I just call the shutdown write side and eventually I get my eof's and everything seems to be properly flushed and clean.
But, it does not seem to work on the IOCP version which seems a bit odd since this should be handled at the OS level and automatically dealt with. I'm fairly confident of the test code given it starts and stops event_base 10 times, runs 1024 sockets through the connection, send/recv and shutdown all without errors. I'll see if I can figure out the problem but it's been a while since I poked the hornet's net which is IOCP... > I was cleaning up some experimental code and wanted to fix up the > network connections to perform a correct/clean socket shutdown handshake. > Unfortunately I can't seem to find any way of doing this through the > existing API, documentation or example code and I'm hoping that I'm simply > missing something. Basically the standard handshake of send a termination > message, shutdown write, continue reading till EOF, shutdown both, close > socket. On the other side basically the same stuff just slightly > different > order of behavior. > > I don't see how I can call shutdown myself on the socket due to > buffered data which may get truncated if I shutdown before it is all > written, and I can't actually find anything in the library or samples > which > calls shutdown to get a starting point to work from. Also, the manual > doesn't cover this detail from what I could see. (It does mention > bufferevent_flush and BEV_FINISHED, but then says not implemented for > sockets.) > > So, if you can point me in the correct direction; that would be > wonderful. > > KB > > *********************************************************************** > To unsubscribe, send an e-mail to majord...@freehaven.net with > unsubscribe libevent-users in the body. *********************************************************************** To unsubscribe, send an e-mail to majord...@freehaven.net with unsubscribe libevent-users in the body.