Scenario: I accept a (TCP) connection, write some data, close the
connection.

Problem: close() does not perform an orderly shutdown, does not resend
unacknowledged data - responds with RST to data/acks sent to me

Non-solution: SO_LINGER, makes close into a blocking call in order to
get orderly shutdown

Incomplete solution: shutdown(SHUT_RDWR), but then what?  Will the OS
close the fd for me once the other end acknowledges, or better yet,
closes its end as well, or do I need to close the fd?  If so, how can I
be notified when the other end acknowledges up to FIN (or timeout) in
order to do so?  (selecting for readable is not a solution; if they have
sent me data I am uninterested in reading, I will select readable)

Obviously, if shutdown fails (it shouldn't, I die on failure), you would
need to close to avoid descriptor leakage.  But do I need to babysit the
descriptor after I have no more interest in it?

Is there a ps-like tool with which I can easily inspect descriptor
usage?

This seems to be a very difficult question; I have found contradictory
(and many obviously wrong) opinions so far, and Stevens' UNP doesn't
address it at all (he seems unaware of the possibility, or else silently
reliant on process termination freeing all descriptors).

--
Jonathan Graehl 
  http://jonathan.graehl.org/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-net" in the body of the message

Reply via email to