gtpc1m30Transmission Control Protocol/Internet Protocol

Sockets

Transmission Control Protocol/Internet Protocol (TCP/IP) support provides a set of C functions that applications can use to access the Internet for transferring or receiving data called socket APIs.

Types of Sockets Supported by TCP/IP

Table 7 shows the types of sockets supported by TCP/IP and the related protocol generally associated with each protocol.

Table 7. Socket Types and Associated Data

Socket type Protocol Description
SOCK_STREAM Transmission Control Protocol (TCP) The stream socket (SOCK_STREAM) interface defines a reliable connection-oriented service. Data is sent without errors or duplication and is received in the same order as it is sent.
SOCK_DGRAM User Datagram Protocol (UDP) The datagram socket (SOCK_DGRAM) interface defines a connectionless service for datagrams, or messages. Datagrams are sent as independent packets. The reliability is not guaranteed, data can be lost or duplicated, and datagrams can arrive out of order. However, datagram sockets have improved performance capability over stream sockets and are easier to use.
SOCK_RAW IP, ICMP, RAW The raw socket (SOCK_RAW) interface allows direct access to lower-layer protocols such as Internet Protocol (IP).
Note:

The type of socket you use is determined by the data you are transmitting:

  • When you are transmitting data where the integrity of the data is high priority, you must use stream sockets.
  • When the data integrity is not high priority (for example, for terminal inquiries), use datagram sockets because of their ease of use and higher performance capability.

Socket Address for the Internet Domain

A socket address for the internet domain is made up of 4 distinct parts defined by 16 bytes:

  1. The first 2 bytes contain the domain parameter, which indicates the address space where communication is taking place.
  2. The next 2 bytes contain the port number, which the TCP/IP software used to differentiate between different applications using the same protocol (TCP or UDP).
  3. The next 4 bytes contain the internet address, which represents a unique network interface.
  4. The remaining bytes in the 16-byte structure are not used.

The internet domain is the only address domain supported by TCP/IP support.