[SDL] SDL_net and broadcasting

Luc-Olivier de Charrière Luc-Olivier.deCharriere at epfl.ch
Sat Sep 28 17:06:01 PDT 2002


**My motivations
I'm currently working on a great GPL game, "globulation2", aviable on 
Thatfor, I need broadcasting ability in the LAN or subnet. (sening to ip
But SDL_net does not provide the abitity to send packet to ip
Therefore, I programmed a UNIX C++ object to allow easy broadcasing, and 
it's working fine on GNU/Linux.
(But I have some header/#define trouble on macosX and Solaris, fixed by 
changing the makefile.)
Therefor it would be nicer to implements broadcasting info SDL, and 
everyone could use it !

**My questions
Is anyone else interested in the broadcasting ability ?
How would you like broadcasting ability to be implemented in SDL_Net ?
Who know about OpenTransport and broadcasting ?
Who is the SDL_net responsible ?

**Technical considerations
I know about UNIX over IP programming, but not OpenTransport at all.
The problem is that you have to change the "socketDefinition" to allow 
This corresponds to "UDPsocket" in SDL_net.
Then I see two possiblilities:

1)Change the
UDPsocket SDLNet_UDP_Open(Uint16 port)
UDPsocket SDLNet_UDP_Open(Uint16 port, int broadcast)
This is cleaner toward UNIX way to see broadcast, but we loose backward 

2)We dynamicaly changes the SocketDefinition's flags before and after 
sending the UDP packet.
This would looks like:  this is only the idea)

if (packets[i]->address.host=INADDR_BROADCASTING)
    int socketDefinition=sock->channel;
    char ttl=1;
    setsockopt(socketDefinition, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, 
    int hold=1;
    setsockopt(socketDefinition, SOL_SOCKET, SO_BROADCAST, &hold, 

// more the recovering part after sending

**Who will do the work
If any choice is made, can programm the UNIX part of it.
But i'm looking for someone to do it for OpenTransport.


Luc-Olivier de Charrière

More information about the SDL mailing list