TUnixSystem::CloseConnection

From: Susan Kasahara (schubert@hep.umn.edu)
Date: Sun Feb 27 2000 - 21:16:10 MET


Hi ROOTer's,
I am using the ROOT Networking classes in a parent/child server configuration.
I've noticed that TUnixSystem::CloseConnection (invoked by TSocket::Close on
our RH Linux system) uses the Unix "shutdown" function to close the socket
instead of the "close" function.   The difference is that "close" will not really
close the socket until the parent/child socket reference count reaches 0 (meaning
both parent & child have closed the socket), whereas "shutdown" closes the
socket regardless of the socket reference count.  In a parent/child configuration,
it's useful to be able to decrement the reference count of the accepted connection
socket in the parent, but leave the socket open in the child.
I'm wondering if the "shutdown" call is really necessary, i.e. instead of

void TUnixSystem::CloseConnection(int sock)
{
   // Close socket.

   if (sock < 0) return;

#if !defined(R__AIX) || defined(_AIX41) || defined(_AIX43)
   ::shutdown(sock, 2);
#endif

   while (::close(sock) == -1 && GetErrno() == EINTR)
      ResetErrno();
}

the function could be modified to:

void TUnixSystem::CloseConnection(int sock)
{
   // Close socket.

   if (sock < 0) return;

   while (::close(sock) == -1 && GetErrno() == EINTR)
      ResetErrno();
}

Thanks for taking the time to look at this.
Susan Kasahara



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:20 MET