SPMA080 April 2021 TM4C1292NCPDT , TM4C1292NCPDT , TM4C1292NCZAD , TM4C1292NCZAD , TM4C1294KCPDT , TM4C1294KCPDT , TM4C1294NCPDT , TM4C1294NCPDT , TM4C1294NCZAD , TM4C1294NCZAD , TM4C1299KCZAD , TM4C1299KCZAD , TM4C1299NCZAD , TM4C1299NCZAD , TM4C129DNCPDT , TM4C129DNCPDT , TM4C129DNCZAD , TM4C129DNCZAD , TM4C129EKCPDT , TM4C129EKCPDT , TM4C129ENCPDT , TM4C129ENCPDT , TM4C129ENCZAD , TM4C129ENCZAD , TM4C129LNCZAD , TM4C129LNCZAD , TM4C129XKCZAD , TM4C129XKCZAD , TM4C129XNCZAD , TM4C129XNCZAD
Table 1-1 lists a typical BSD socket APIs. Figure 1-3 shows a simplified flowchart of a TCP client-server communication using the BSD socket APIs. Figure 1-4 shows the APIs usage of a UDP communication.
Function Category | API | Description |
---|---|---|
Socket connection | socket | Creates a new socket of a certain type, identified by an integer number, and allocates system resources to it. |
bind | Is typically used on the server side, and associates a socket with a socket address structure, i.e. a specified local IP address and a port number. | |
listen | Is used on the server side, and causes a bound TCP socket to enter listening state. | |
accept | Is used on the server side. It accepts a received incoming attempt to create a new TCP connection from the remote client, and creates a new socket associated with the socket address pair of this connection. | |
connect | Is used on the client side, and assigns a free local port number to a socket. In case of a TCP socket, it causes an attempt to establish a new TCP connection. | |
Receiving data | recv | Used for receiving data. Normally used only on a connected socket. |
recvfrom | Used for receiving data. May be used to receive data on a socket whether or not it is connection-oriented. | |
Sending data | send | Used for sending data. Normally used for TCP SOCK_STREAM connected sockets. |
sendto | Used for sending data. Normally used for UDP SOCK_DGRAM unconnected datagram sockets. | |
I/O multiplexing | poll | Is used to check on the state of a socket in a set of sockets. The set can be tested to see if any socket can be written to, read from or if an error occurred. |
select | Is used to suspend, waiting for one or more of a provided list of sockets to be ready to read, ready to write, or that have errors. | |
Closing connection | close | Close the TCP connection. |
Socket options | setsocketopt | Is used to set a particular socket option for the specified socket. |
getsockopt | Is used to retrieve the current value of a particular socket option for the specified socket. |