[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
UDPsocket SDLNet_UDP_Open(Uint16 port)
Open a socket to be used for UDP packet sending and/or receiving.
If a non-zero port is given it will be used, otherwise any open port number will
be used automatically.
Unlike TCP sockets, this socket does not require a remote host IP to connect to, this is
because UDP ports are never actually connected like TCP ports are.
This socket is able to send and receive directly after this simple creation.
Returns: a valid UDPsocket on success. NULL is returned on errors, such as when it's not able to create a socket, or it cannot assign the non-zero port as requested.
Note that below I say server, but clients may also open a specific port, though it is prefered that a client be more flexible, given that the port may be already allocated by another process, such as a server. In such a case you will not be able to open the socket, and your program will be stuck, so it is better to just use whatever port you are given by using a specified port of zero. Then the client will always work. The client can inform the server what port to talk back to, or the server can just look at the source of the packets it is receiving to know where to respond to.
|
|
See Also:
3.4.2 SDLNet_UDP_Close,
4.3 UDPsocket
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |