bin/176713: [patch] nc(1) closes network socket too soon

Ronald F. Guilmette rfg at tristatelogic.com
Wed Jul 24 23:43:43 UTC 2013


In message <CAJ-Vmo=OcMkqeo4AA9MdZwbhabu0uQV+Ec_1qKt4AeLeWN3gqA at mail.gmail.com>
, you wrote:

>Hi,
>
>Well, I've done this before. More than once. I'm glad that you've
>stuck through helping me understand what nc is doing; I'm
>unfortunately busy doing other things
>
>What you end up doing is:
>
>* tracking the state of the two sockets, both for read EOF and write EOF;
>* whenever you get an EOF from one of the above four conditions, you
>see whether you can still make progress. If so, you don't close the
>socket - you just stop registering for that event. (Eg, if you see
>read EOF on a socket, stop registering for read)
>* if you see that both sides are read EOF'ed, then you can't possibly
>make any more progress, right?
>* .. no, you also have to THEN ensure that all the data you have
>queued is written, OR that you hit write EOF (and thus can't make any
>more progress anyway)
>
>_then_ you shut things down.
>
>Anyway. Leave it with me. Bug me if I don't commit either your fix, or
>rearchitect it to do what I said above (and then test it, obviously :)


Thank you.

Please consider yourself bugged.
(1/2 :-)


More information about the freebsd-hackers mailing list