Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 May 2001 02:10:14 -0700
From:      "Jonathan Graehl" <jonathan@graehl.org>
To:        <freebsd-net@freebsd.org>
Subject:   Do I need to close after shutdown if I don't want to leak descriptors? (making sure TCP retransmits all my data)
Message-ID:  <000001c0d6d5$87607e80$6dfeac40@straylight.com>

Next in thread | Raw E-Mail | Index | Archive | Help
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 majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?000001c0d6d5$87607e80$6dfeac40>