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

## 3.4 UDP Sockets

These functions are used to work with UDP Sockets.
UDP is connectionless, but can be used as if it is connected, in the sense that you don't have to address every outgoing packet if you don't want to. This is done by binding a socket to remote IP address and port pairs.
UDP has no delivery guarantees, each packet has a chance of never getting to the destination.
UDP packets may also be received completely out of order, as compared to the order of sending them.
All these seeming bad qualities are made up for in speed. UDP is faster than TCP, and so many games and speed sensitive applications, which may also be sending redundant data anyways, such as a game state, prefer to use UDP for the speed benefits.

SDL_net has a concept of channels, which help you to matchup packets to specific clients easier. These channel numbers are not transmitted in the UDP packet data, but rather when a UDP socket receives or sends packets, a channel number may be used instead of an IPaddress to refer to the source or destination. You might prefer not to use channels at all, which is fine. SDL_net provides them only as an optional convenience.

> General

> 3.4.1 SDLNet_UDP_Open |  | Create a UDP socket
> 3.4.2 SDLNet_UDP_Close |  | Close and free a UDP socket

> Channel Binding

> 3.4.3 SDLNet_UDP_Bind |  | Assign an IP address number to a socket channel
> 3.4.4 SDLNet_UDP_Unbind |  | Remove all assigned IP addresses from a socket channel
> 3.4.5 SDLNet_UDP_GetPeerAddress |  | Get the assigned IP address for a socket channel or get the port you opened the socket with

> Single UDPpacket

> 3.4.6 SDLNet_UDP_Send |  | Send a UDPpacket
> 3.4.7 SDLNet_UDP_Recv |  | Receive into a UDPpacket

> Many UDPpackets in a vector (array)

> 3.4.8 SDLNet_UDP_SendV |  | Send a UDPpacket vector
> 3.4.9 SDLNet_UDP_RecvV |  | Receive into a UDPpacket vector

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

This document was generated on November, 3 2009 using texi2html