What I do:

Add

long connect_time;

To the descriptor_data structure.

In init_descriptor() assign d->connect_time to time(0);

Then in game_loop_unix, where it checks for a new connection do this where
it loops
Through the descriptors:

if (d->connected > CON_PLAYING) {
   if (d->character) {
     if ( (time(0) - d->connect_time) > 15*60)
       close_socket(d);
    }
}

Anyone who hasn't made it into the mud within 15 minutes get "teh boot"

Jason

> -----Original Message-----
> From: Michael Barton [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, December 17, 2003 4:39 AM
> To: [email protected]
> Subject: Re: Timeout at greet screen
> 
> The problem is that a connection sitting at the greeting 
> isn't receiving any data.  It is in the nature of TCP that it 
> can't detect a lost connection until you try to send it data.
> 
> There's a keepalive flag you can set on the socket (on most 
> OS's), that will cause it to periodically send probe packets 
> to see if the socket is still connected, though this can take 
> over 2 hours to detect a disconnection (RFC 1122).
>         int x = 1;
>         if (setsockopt(desc, SOL_SOCKET, SO_KEEPALIVE,
>           (void *) &x, sizeof(x) ) < 0)
>         {
>             perror( "SO_KEEPALIVE" );
>             close(desc);
>         }
> Well, some OS's, that 2 hours thing is configurable.
> 
> The other option is to add a timer to the descriptor like the 
> one in char_data, and disconnect when it gets too high.
> 
> --Palrich.
> 
> ----- Original Message -----
> From: "Sarix" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Wednesday, December 17, 2003 2:33 AM
> Subject: Timeout at greet screen
> 
> 
> > I'm not big on socket coding, but is there a way I can set a shorter
> timeout
> > time on connections that just sit at the greet screen? I 
> have a few users
> > that for some reason each time they connect their client 
> has to connect
> > twice and one sits at the greet screen. And it would be 
> nice if I could
> have
> > the mud disconnect those who just sit there.
> >
> >
> > -- 
> > ROM mailing list
> > [email protected]
> > http://www.rom.org/cgi-bin/mailman/listinfo/rom
> 
> 
> -- 
> ROM mailing list
> [email protected]
> http://www.rom.org/cgi-bin/mailman/listinfo/rom
> 

Reply via email to