[ENet-discuss] How to temporarily keep a host from accepting incoming connection requests?

Lee Salzman lsalzman1 at cox.net
Thu Jun 17 03:16:39 PDT 2010


I am not entirely sure why you would even want a password, especially of 
such small size, if your goal is just to entirely block connections? It 
may as well be a boolean flag in the host that, when set, drops all 
connect packets there.

Lee

Benoit Germain wrote:
>
> Hello,
>
> I have a situation where I want a host to communicate with remote 
> peers normally, while at the same time ignoring incoming connection 
> requests. I could of course put my application in a mode where I 
> disconnect immediately peers for which I receive a CONNECT event, but 
> I’d rather leave the peers alone and make sure I get connect events 
> when I am ready to accept them. I was thinking that I could 
> “short-circuit” connect commands. This could be made with a 
> rudimentary password mechanism, as such (of course this requires the 
> new connect data introduced in 1.3.0):
>
> Add this in the host structure (and add proper initialization where 
> required)
>
> Typedef struct _EnetHost
>
> {
>
>>
> enet_uint32 sessionPassword;
>
> };
>
> Add the following at the beginning of enet_protocol_handle_connect():
>
> switch( host-> sessionPassword)
>
> {
>
> case 0: // session is opened, proceed
>
> break;
>
> case 0xffffffff: // session is locked, ignore all requests
>
> return NULL;
>
> default: // session is password-protected, proceed only if incoming 
> request data matches password
>
> if( ENET_NET_TO_HOST_32( command->connect.data) != host->sessionPassword)
>
> return NULL;
>
> }
>
> Is this the proper place and way to do what I want, or should I expect 
> bad things from this?
>
> Regards,
>
> Benoit.
>
>   



More information about the ENet-discuss mailing list