[Home] [Groups] - Message: [Prev in Group] [Next in Group]

nu.kanga.list.mud-dev

8942: [MUD-Dev] Re: Quick socket question

[Full Header] [Plain Text]
From: Chris Gray <cg@ami-cg.GraySage.Edmonton.AB.CA>
Newsgroups: nu.kanga.list.mud-dev
Date: Sat, 7 Nov 1998 19:50:16 -0700
Organization: Kanga.Nu
[Dr. Cat:]

 >I thought at first it was because I wasn't closing the socket when the 
 >accept() problem I was having crashed it.  But I did a proper operator 
 >shutdown, which takes the bound socket and does shutdown(mastsock, 2)
 >and close(mastsock) before existing.  Do I need to do anything more on 
 >closing to make sure the port is freed up, even if there's some 
 >recalcitrant user's machine out there still desperately trying to talk to 
 >it?  Or is there a setsockopt option I need to set differently?  Or is 
 >there a sysadmin tweak to change that timeout value?  If anyone's dealt 
 >with this issue under Linux before (or any other Unix that has the same 
 >issue) I'd appreciate a pointer.  :X)

I still get a few delays of a minute or two, and sometimes I don't, but
that is about the maximum. I'm running RedHat 5.1. Perhaps that's
because I always manage to get the shutdown and close in properly.
This is it, literally:

static void
killSocket(int s)
{

    TRACE("killSocket", s);
    shutdown(s, 2);
#if defined(_WIN32)
    closesocket(s);
#elif defined(AMIGA)
    CloseSocket(s);
#else
    close(s);
#endif
}

One thing you could try (I thought I had it in!) is to use setsockopt
with SO_REUSEADDR.

--
Don't design inefficiency in - it'll happen in the implementation. - me

Chris Gray     cg@ami-cg.GraySage.Edmonton.AB.CA