[ENet-discuss] ENet-discuss Digest, Vol 61, Issue 1

Lee Salzman lsalzman1 at cox.net
Tue Jun 3 15:26:56 PDT 2008


Note, you don't set the client's address to ENET_HOST_BROADCAST (pass in 
NULL for the client's address structure to enet_host_create as usual). 
You attempt to connect to ENET_HOST_BROADCAST, which will send out the 
connection request to the broadcast address, which will just broadcast 
anywhere on the LAN. If there's something on the other end of the LAN 
waiting to accept, it will get a connection from it. If there are 
multiple servers on the other end that pick up the broadcasted connect 
request, then whichever replies back first wins. There should be nothing 
different about it otherwise.

You don't have to do anything special for LAN vs. internet for server 
addresses. Same stuff I described in previous email about IP applies.

Lee

Ben Johnson wrote:
> Wow, thanks for the fast reply.
>  
> You cleared up quite a bit of my confusion, too.
>  
> I ditched my vector of peer pointers, and am now using the host->peers 
> instead.
> Also, instead of using a dummy connection when I want to play 
> on non-dedicated server, I do something like this:
>  
> maxPlayers = 12;
> if(!dedicated) maxPlayers--;
> host = enet_host_create(&address, maxPlayers, 0, 0);
> serverPlayer = maxPlayers;
>  
> this will only allow for 11 other players to join. And they will fill 
> spots 0 to 10 in the host->peers array.
> The player the server now controls is player[serverPlayer] - which is 
> the 12th and final player. So I don't have to worry about it being 
> replaced, etc..
>  
> Hooray, first 4 questions solved!
>  
> As far as question 5 goes, I'm now using ENET_HOST_ANY. Regarding 
> LAN.. what should I do then? Keep it as ENET_HOST_ANY? I read 
> somewhere that the client should then set it's address to 
> ENET_HOST_BROADCAST, and that will return any server addresses? I 
> tried, but it didn't work.. Do I have to connect twice or something? 
> Once to find the address, and then again to connect to it?
>  
> Also, can a server host for both LAN and the internet at the same 
> time? So anyone can join, whether they're in the LAN or on the net? If 
> not, for testing purposes, is it possible for me to use my second 
> computer which is on the LAN, but get it to join via the internet, so 
> I can check to see if I've got both the LAN connection and the 
> internet connections working properly. I've been reading a lot about 
> NAT punch-through, so I imagine I might have to deal with that in the 
> future, as I am using a router.. but hopefully I can get at least LAN 
> working first.
>  
> Thanks again!
> Ben.



More information about the ENet-discuss mailing list