so: socket functions |
Top Previous Next |
The socket functions are an API used for transferring (sending and receiving) data across a network.
A socket is an abstract representation for the local endpoint of a communication path. The communication path can be across a network to a PC (or similar) or back to the device itself. This abstraction is introduced so that a single interface can be used for multiple network protocols. (e.g. TCP or UDP)
There are two types of sockets: •Stream sockets •Datagram sockets
The images below shows the use of a Stream socket and a Datagram socket:
The default behavior of the socket functions is to block until the function is completed. It is possible to configure a socket to be non-blocking, which means that the socket functions return immediately with an error (-4, would block), while the function is completed asynchronous.
The socket API have support for secure connections using the Transport Layer Security (TLS) protocol. This is built into the socket functions, so that no other functions are necessary. A secure connection can be created both implicit and explicit. (Implicit being that TLS is negotiated immediately after the connection is established, and Explicit being that TLS is negotiated after communicating on the socket)
Secure connections are only available for TCP sockets. While secure connections can be both blocking and non-blocking, for implicit security the socket MUST be blocking. (The socket can be switched to non-blocking after the secure connection is established)
The image below shows an example of a secure connection:
Functions for sockets:
Option structures:
Functions for socket address:
The implementation of sockets have the following limitations: •The maximum number of sockets is limited to 512. The sockets are shared with FTP.
|