[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.4.3 SDLNet_UDP_Bind

int SDLNet_UDP_Bind(UDPsocket sock, int channel, IPaddress *address)

sock
the UDPsocket on which to assign the address.
channel
The channel to assign address to. This should be less than
SDLNET_MAX_UDPCHANNELS. If -1 is used, then the first unbound channel will be used, this should only be used for incomming packet filtering, as it will find the first channel with less than SDLNET_MAX_UDPADDRESSES assigned to it and use that one.
address
The resolved IPaddress to assign to the socket's channel. The host and port are both used.
It is not helpful to bind 0.0.0.0 to a channel.

Bind an address to a channel on a socket.
Incoming packets are only allowed from bound addresses for the socket channel.
All outgoing packets on that channel, regardless of the packets internal address, will attempt to send once on each bound address on that channel.
You may assign up to SDLNET_MAX_UDPADDRESSES to each channel.

Returns: The channel number that was bound. -1 is returned on errors, such as no free channels, or this channel has SDLNET_MAX_UDPADDRESSES already assigned to it, or you have used a channel higher or equal to SDLNET_MAX_UDPCHANNELS, or lower than -1.

 
// Bind address to the first free channel
//UDPsocket udpsock;
//IPaddress *address;
int channel;

channel=SDLNet_UDP_Bind(udpsock, -1, address);
if(channel==-1) {
    printf("SDLNet_UDP_Bind: %s\n", SDLNet_GetError());
    // do something because we failed to bind
}

See Also:
3.4.4 SDLNet_UDP_Unbind, 3.4.5 SDLNet_UDP_GetPeerAddress, 3.4.1 SDLNet_UDP_Open, 4.1 IPaddress, 4.3 UDPsocket



This document was generated on November, 3 2009 using texi2html