[comp.protocols.tcp-ip.ibmpc] setsocketopt

sluggo@unix.cis.pitt.edu (Steve Kalinowski) (11/13/89)

I am working on some code using Sun PC-NFS toolkit to talk to
a Sun and a 'company-made' VMEbus computer.  Everything is
great except for making the close() command.  I do a 
shutdown(sd,2) and then close, but the close() takes ~20secs
on my PC-AT.  This only happens on the socket open to the
proprietary box (w/ a CMC ENP10 card w/ TCP roms) is closed.
The socket to the Sun works fine.  So I figured I needed to
set the SO_DONTLINGER option for the socket, but...

I am having a bit of trouble using PC-NFS's setsockopt call.
I want to set the DONTLINGER option so that my close() calls will
return immediately, but I keep getting EMFILE (errno==24) from
the setopt.  (The call DOES work for SO_REUSEADDR).
A bit of the code follows:
        .
        .
        .
if ((sock_desc = socket (AF_INET, conn_id->conn_type, 0)) < 0)
    printf("socket() failed w/ error %d\n", errno);

if (setsockopt (sock_desc, SOL_SOCKET, SO_DONTLINGER, 0, 0) < 0)
{
    close(sock_desc);
    printf("setsockopt() failed w/ error %d\n", errno);
}
        .
        .
        .

This code is used on my Sun 3/50 w/ success.  I thought that there
might be data stranded in the socket, so i added a recv, which hung.
When the Sun closes its connection to our 'black box' the close is
quick.

Any advice will be most appreciated.

steve'

p.s. I know that EMFILE is not an expected result (according to the
     manual =8^) ).  Also, I CAN get this to run w/o the DONTLINGER,
     so I don't believe the error indication.