Sockets

The basis of UDP and TCP communication on the application level are sockets. A socket is a data structure holding information about a connection. It virtually connects a local and a remote process for data communication and acts as an interface between user level and transport layer.

sockets.jpg

You must open a socket first before any data can be transferred. A socket specifies the address and port number of the remote host, the local port number, and the transfer protocol ( UDP or TCP). In the D.SignT TCP/IP stack, the data type is also specified. This allows to transfer data directly between a user data buffer and the Ethernet Controller. Data type conversions and memory alignments, depending on the DSP's data representation, are performed in background.

A socket does not specify the direction of the data transfer, each socket can handle bi-directional transfers. A connection can either be a server or a client. A server connection listens for incoming data on its source port. If data is received, the server responds. A client however actively connects to a server, sends data and receives the server's response.

Addresses can be numerical IP addresses, or symbolic host names if a DNS server is available to resolve them. Port numbers above 1025 are user-defined, lower port numbers have dedicated functions - the so-called "well-known ports". Here is a list of all well-known and registered ports: http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

A socket contains additional information about a connection, e.g. the error code if an operation should fail. If a function call returns a SOCKET_ERROR, you can read the error code from the socket structure member socket_struct ->error_code.

Refer to chapter Socket Modules for SOCKET function reference