std.socket Package

Function Description

The socket package is used for network communication, and provides functions such as starting a Socket server, connecting to a Socket server, sending data, and receiving data.

Three Socket types of UDP, TCP, and UDS are supported. You can select a type as required.

User Datagram Protocol (UDP) is a connectionless transmission protocol. It does not provide reliability or flow control, but features low delay and low network overhead. UDP is mainly used in applications with high real time requirements, such as live video streaming and online gaming.

Transmission Control Protocol (TCP) is a connection-oriented and reliable transmission protocol. As one of commonly used transmission protocols on Internet, it provides functions such as reliable data transmission, flow control, congestion control, error detection, and flow management.

Unix Domain Socket (UDS) is a mechanism used for communication between processes on one computer. Unlike network sockets, the UDS does not require network protocol stacks or network devices. Therefore, it features faster communication, lower latency and higher throughput.

The class inheritance relationship of Socket provided by the library is as follows:

Hierarchy
 Resource
 ├StreamingSocket
 │   ├TcpSocket
 │   └UnixSocket
 │
 ├DatagramSocket
 │   ├UdpSocket
 │   └UnixDatagramSocket
 │
 └ServerSocket
    ├TcpServerSocket
    └UnixServerSocket

API List

Constant & Variable

NameDescription
IPV4_ALL_ROUTERSpecifies the IPv4 multicast address.
IPV4_ALL_SYSTEMSpecifies the IPv4 multicast address.
IPV4_BROADCASTSpecifies the IPv4 broadcast address.
IPV4_LOCAL_HOSTSpecifies the local IPv4 address.
IPV4_ZEROSpecifies the universal IPv4 address.
IPV6_INTERFACE_LOCAL_ALL_NODESSpecifies the IPv6 multicast addresses of all nodes within the node-local scope.
IPV6_LINK_LOCAL_ALL_NODESSpecifies the IPv6 multicast addresses of all nodes within the link-local scope.
IPV6_LINK_LOCAL_ALL_ROUTERSSpecifies the IPv6 multicast addresses of all routers within the link-local scope.
IPV6_LOOPBACKSpecifies the loopback address (local address).
IPV6_ZEROSpecifies the universal IPv6 address.

Interface

NameDescription
DatagramSocketSpecifies a socket for receiving and reading packets.
ServerSocketProvides APIs required by Socket of the server.
StreamingSocketSpecifies Socket running in duplex stream mode, which is readable and writable.

Class

NameDescription
IPMaskSpecifies the IP mask, IP address, and routing address.
RawSocketProvides basic functions of a socket.
SocketAddressSpecifies the socket address with a specific type, address, and port.
SocketAddressWithMaskProvides SocketAddress with a mask.
TcpServerSocketSpecifies the server that monitors TCP connections.
TcpSocketSpecifies the client that requests a TCP connection.
UdpSocketProvides UDP packet communication.
UnixDatagramSocketProvides the packet-based host communication capability.
UnixServerSocketProvides a duplex stream-based server for host communication.
UnixSocketProvides a duplex stream-based client for host communication.

Enumeration

NameDescription
SocketAddressKindSpecifies the Internet communication protocol type.
SocketNetSpecifies the transport layer protocol type.

Struct

NameDescription
OptionLevelProvides common socket option levels.
OptionNameProvides common socket options.
ProtocolTypeProvides common socket protocols, and allows the socket protocols to be constructed by specifying the value of Int32.
RawAddressCreates and obtains the communication address of RawSocket.
SocketDomainProvides common socket communication domains, and allows the socket communication domains to be constructed by specifying the value of Int32.
SocketKeepAliveConfigConfigures the TCP KeepAlive attribute.
SocketOptionsStores some constants for setting socket options for subsequent calling.
SocketTypeProvides common socket types and allows the socket types to be constructed by specifying the value of Int32.

Exception Class

NameDescription
SocketExceptionProvides socket-related exception processing.
SocketTimeoutExceptionProvides exception processing related to the character format.