[ENet-discuss] How to temporarily keep a host from accepting incoming connection requests?
Philip Bennefall
philip at u7142039.fsdata.se
Sun Jun 20 17:30:23 PDT 2010
Hi Lee,
I also am interested in doing something like this, as I can then make it
even easier for the users of my scripting engine to set up hosts that accept
connections at certain times but not at others. Exactly which function would
i have to modify to accomplish this? I assume I should be looking in the
file called protocol.c? Some hints would be very much appreciated. Perhaps a
quick wrapper function in the next minor build
(enet_host_disable_incoming_connections) or similar?
Kind regards,
Philip Bennefall
----- Original Message -----
From: "Lee Salzman" <lsalzman1 at cox.net>
To: "Discussion of the ENet library" <enet-discuss at cubik.org>
Sent: Thursday, June 17, 2010 12:16 PM
Subject: Re: [ENet-discuss] How to temporarily keep a host from accepting
incoming connection requests?
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.
>
>
_______________________________________________
ENet-discuss mailing list
ENet-discuss at cubik.org
http://lists.cubik.org/mailman/listinfo/enet-discuss
--------------------------------------------------------------------------------
Internal Virus Database is out of date.
Checked by AVG - www.avg.com
Version: 8.5.432 / Virus Database: 271.1.1/2662 - Release Date: 02/01/10
12:37:00
More information about the ENet-discuss
mailing list