roes@phcoms.seri.philips.nl (Aloys Roes) (02/16/90)
We have a network application that uses the socket interface. The client-side used to get a free TCP socket on the local system and then connect to a Well Known Socket at the remote node. However, to be able to completely control access over the wide area network we decided that we would use a fixed set of local portnumbers for outgoing active connections. The client will try to bind to each of these ports in sequence until it finds a free one. When the client is done with it's work it sends a confirmation message to the server process. The server will close the connection and the client will do the same. We notice however that after the close the socket sticks around for a while (between 1 and 4 minutes depending on the implementation). We tried to change the code so that the client side closes first but then then the server side will have the connection open for a while. We checked the TCP/IP documentation and that states that this is what the TCP layer ought to do. It waits 2 times the Maximum Segment Lifetime to ensure that the remote side receives the final ack. In our case however it restricts us very much in the number of open connection we can have between any 2 hosts. So the question is, whether there is a way to avoid this delay after the connection has been closed e.g. decrease the MSL just before the 'close' or use 'shutdown' instead of 'close'. Thanks in advance, Aloys Roes, Philips Components, Building BC-136, | Tel. : + 31 40 72 30 62 P.O.Box 218, 5600 MD Eindhoven, The Netherlands | Email: roes@seri.philips.nl -- regards, Aloys Roes, Philips Components, Building BC-136, | Tel. : + 31 40 72 30 62 P.O.Box 218, 5600 MD Eindhoven, The Netherlands | Email: roes@seri.philips.nl
dls@mentor.cc.purdue.edu (David L Stevens) (02/27/90)
You can use a shutdown(2), but beware! Shutdown(2) (both ways, anyway) is equivalent to TCP's ABORT() user request. In particular, if any data is buffered in the kernel locally waiting to be sent, it will be dropped and the other side will never see it. Some protocols have (essentially) extraneous acknowledgements at the application level, so you really can tell when you've gotten all the data, and then shutdown(2)'s ok. In most cases, you really want a close(2). -- +-DLS (dls@mentor.cc.purdue.edu)