[ENet-discuss] ENET_PORT_BROADCAST

Lee Salzman lsalzman1 at cox.net
Mon Sep 29 10:51:57 PDT 2008


You must set up a raw UDP socket on both ends (on the server and the 
server browser)
specifically for pinging/ponging, separate from any existing connections 
you are using.
You can use the ENet socket functions to do this.  Once there, you have 
two options:

1. Have each of these UDP sockets bound to the same address/port. If you 
use the SO_REUSEADDR
option, you can have multiple programs bound to the same host AND port 
on a single computer or
network, and they will all still get a packet so long as it is sent to 
the broadcast address. Send out a
ping packet periodically to the broadcast address and this specific port 
the pong sockets are
listening on, and have them reply to the sender with their port, if 
necessary, address as well.

2. Set up multicasting (would require some work outside of the ENet 
socket functions), then
pretty much do as above, sending out the ping to the specific 
multicasting address instead of
the broadcast address.

The broadcast with SO_REUSEADDR approach is what I have used so far to 
date, and it is probably
easiest.

Lee

Ben Johnson wrote:
> Hey all.. I know ENET_PORT_BROADCAST doesn't exist. But is there 
> something similar? Suppose I'm at a LAN party and there are many
> servers running my game. But they're all running with 
> different/unknown ports. I can use ENET_HOST_BROADCAST to find the 
> IP.. but it seems
> I need to know the exact port that is being used to find the server. I 
> could do a loop and scan through every IP from 1 to 65535, but that'd 
> be silly.
>  
> Furthermore, even if I did know the port.. using ENET_HOST_BROADCAST 
> will stop searching once the first server has replied, yes?
> What would be the best way to continue searching so I can connect to 
> (and request server info from) all the possible servers on the LAN.
>  
> Thanks!
>  
> Ben.
>   


More information about the ENet-discuss mailing list