UDP
Server
sl_Socket
sl_Bind
sl_RecvFrom
sl_SendTo
sl_SendTo
sl_RecvFrom
sl_Close
sl_Close
1. Open a socket
2. Bind port
3. Data Exchange
4. Close the socket
UDP
Client
3. Connection-like
Data Exchange
sl_Socket
sl_Send
sl_Recv
1. Open a socket
4. Close the socket
Sl_Connect
sl_Bind
2. Bind the source
port
±
bind is
optionally in client
socket and not used
in most applications
3. Connectionless
Data Exchange
Socket Working Flow
86
SWRU455A – February 2017 – Revised March 2017
Copyright © 2017, Texas Instruments Incorporated
Socket
6.5.2 UDP
UDP is a connectionless transport protocol. It does not require establishing a connection with a peer
socket, and each packet is individually managed. However, the SimpleLink device lets the host application
use UDP either as a connectionless or a connection-oriented protocol. In the connection-oriented mode,
received packets with a different source than the connect source are dropped. In UDP there are no client
and server sides. Both sides can initiate data exchange or wait for reception of data. In most applications
one side waits for data reception and one side initiates the data exchange. The side that waits for data
reception is related as a server and the side that initiates the data exchange is related as a client.
shows these two methods:
Figure 6-2. UDP Socket Flow
1. Open the UDP socket. Use family type: SL_AF_INET for IPv4, use SL_AF_INET6 for IPv6.
2. Bind the source port. This step is optional. If sl_Bind is not called, the SimpleLink device automatically
binds a random source port. In practice, the server side must bind the port to define the destination
port to the other side.
3. Data Exchange
•
Connectionless
–
Send Data – The host application must provide the destination address and port. To send data
from the IPv6 socket to an IPv4 socket, the IPV4 destination address in sl_SendTo must be
mapped to IPv6 format (for example, ::00:ffff:ipv4).
–
Receive Data – The host application must provide the source address and port. The IPv6
socket can receive data from the IPv4 socket, by mapping the source address to IPv6 format
(for example, ::00:ffff:ipv4).
•
Connection-Oriented
–
Connect – Calling the API sl_Connect for UDP sockets defines the destination address. By