[ENet-discuss] ENet-discuss Digest, Vol 101, Issue 2

Sebastian Ahlman sebastian.ahlman at gmail.com
Mon Oct 17 12:54:52 PDT 2011


Thanks for clearing this up for me. The tutorial on ENet's site claims that
"Clients in ENet are similarly constructed with
enet_host_create()<http://enet.bespin.org/group__host.html#ga5567a95d7a45521dc9cba93a9066c940>
when
no address is specified to bind the host to.", which is why I have always
created my game clients with NULL passed as the first parameter to
enet_host_create().

Does this mean that technically a third party could connect to the peer to
be used as a client, provided that:

1. the third party gets the address and port number correct and
2. the client has not yet connected to the peer it considers the "server"?

Also, does the host field of the address struct have any meaning on a client
peer, ie. a peer that does not "listen" for connections, but only connects
to other peers? Should I use ENET_HOST_ANY on the clients as well, if I want
to be able to connect to "any server"?

Thanks again!

//Sebastian

On Mon, Oct 17, 2011 at 10:00 PM, <enet-discuss-request at cubik.org> wrote:

> Send ENet-discuss mailing list submissions to
>        enet-discuss at cubik.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://lists.cubik.org/mailman/listinfo/enet-discuss
> or, via email, send a message with subject or body 'help' to
>        enet-discuss-request at cubik.org
>
> You can reach the person managing the list at
>        enet-discuss-owner at cubik.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of ENet-discuss digest..."
>
>
> Today's Topics:
>
>   1.  Is the client port always random? (Sebastian Ahlman)
>   2. Re:  Is the client port always random? (Lee Salzman)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 17 Oct 2011 21:09:33 +0300
> From: Sebastian Ahlman <sebastian.ahlman at gmail.com>
> To: enet-discuss at cubik.org
> Subject: [ENet-discuss] Is the client port always random?
> Message-ID:
>        <CAOzyQYFbU2jSXmB5Zj1Srecw4iFsc7GSVwiz96k+nf9qc4MS=w at mail.gmail.com
> >
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi!
>
> This might seem like a stupid question, so I apologize in advance if I have
> misunderstood something. I have used ENet for quite some time now, not
> paying that much attention to what ports I am using, and everything has
> worked fine. I am currently investigating how to incorporate NAT punch
> through using ENet, and one thing came to mind:
>
> Say I have a server and a client. The server creates a host
> using enet_host_create() and passes in the following address:
>
> ENetAddress address;
> address.host = ENET_HOST_ANY;
> address.port = 1234;
>
> Okay, so now I can create a client on the other end and connect to the
> server using its IP address and port 1234. When the server receives the
> data, it prints it to the console along with the IP and port of the sender.
> Up until this point I have always assumed that the port of the client would
> also be 1234, but this does not seem to be that case. The port changes
> every
> time I connect to the server.
>
> This might not be something that prevents me from doing NAT punch through
> (though it just as well might, I have not yet done it), but I would like to
> understand how the system chooses the port for the client, and if there is
> a
> way to specify the port to be used. Also, is there any reason I would want
> to specify the port, or is it better to allow the system to choose it for
> me?
>
> Thank you!
>
> //Sebastian Ahlman
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://lists.cubik.org/pipermail/enet-discuss/attachments/20111017/e0f3131d/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Mon, 17 Oct 2011 14:58:54 +0300
> From: Lee Salzman <lsalzman at gmail.com>
> To: Discussion of the ENet library <enet-discuss at cubik.org>
> Subject: Re: [ENet-discuss] Is the client port always random?
> Message-ID: <4E9C187E.7060406 at gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> The port is whatever the operating system chooses IF you do not specify a
> port. So just specify a port, like you did in the code below. There's really
> no such thing as an ENet server or client, as all providing an address to
> enet_host_create() does is give a preference instead of letting the OS
> choose. What you consider a server or client is a matter of interpretation,
> not of code policy in ENet.
>
> On 10/17/2011 09:09 PM, Sebastian Ahlman wrote:
> > Hi!
> >
> > This might seem like a stupid question, so I apologize in advance if I
> have misunderstood something. I have used ENet for quite some time now, not
> paying that much attention to what ports I am using, and everything has
> worked fine. I am currently investigating how to incorporate NAT punch
> through using ENet, and one thing came to mind:
> >
> > Say I have a server and a client. The server creates a host using
> enet_host_create() and passes in the following address:
> >
> > ENetAddress address;
> > address.host = ENET_HOST_ANY;
> > address.port = 1234;
> >
> > Okay, so now I can create a client on the other end and connect to the
> server using its IP address and port 1234. When the server receives the
> data, it prints it to the console along with the IP and port of the sender.
> Up until this point I have always assumed that the port of the client would
> also be 1234, but this does not seem to be that case. The port changes every
> time I connect to the server.
> >
> > This might not be something that prevents me from doing NAT punch through
> (though it just as well might, I have not yet done it), but I would like to
> understand how the system chooses the port for the client, and if there is a
> way to specify the port to be used. Also, is there any reason I would want
> to specify the port, or is it better to allow the system to choose it for
> me?
> >
> > Thank you!
> >
> > //Sebastian Ahlman
>
>
> ------------------------------
>
> _______________________________________________
> ENet-discuss mailing list
> ENet-discuss at cubik.org
> http://lists.cubik.org/mailman/listinfo/enet-discuss
>
>
> End of ENet-discuss Digest, Vol 101, Issue 2
> ********************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubik.org/pipermail/enet-discuss/attachments/20111017/c9c47b83/attachment.html>


More information about the ENet-discuss mailing list