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

3.4.5 SDLNet_UDP_GetPeerAddress

IPaddress *SDLNet_UDP_GetPeerAddress(UDPsocket sock, int channel)

sock
A valid UDPsocket that probably has an address assigned to the channel.
channel
The channel to get the primary address from in the socket. This may also be -1 to get the port which this socket is bound to on the local computer.

Get the primary address assigned to this channel. Only the first bound address is returned.
When channel is -1, get the port that this socket is bound to on the local computer, this only means something if you opened the socket with a specific port number.
Do not free the returned IPaddress pointer.

Returns: a pointer to an IPaddress. NULL is returned for unbound channels and on any errors.

 
// get the primary address bound to UDPsocket channel 0
//UDPsocket udpsock;
IPaddress *address;

address=SDLNet_UDP_GetPeerAddress(udpsock, 0);
if(!address) {
    printf("SDLNet_UDP_GetPeerAddress: %s\n", SDLNet_GetError());
    // do something because we failed to get the address
}
else {
    // perhaps print out address->host and address->port
}

See Also:
3.4.3 SDLNet_UDP_Bind, 3.4.4 SDLNet_UDP_Unbind, 4.1 IPaddress, 4.3 UDPsocket



This document was generated on November, 3 2009 using texi2html