std.net

Features

The net package is used for network communication, providing functionalities such as starting a Socket server, connecting to a Socket server, sending data, receiving data, as well as related data structures for IP addresses, IP prefixes (also known as IP subnets), and Socket addresses.

We support three types of Socket: UDP/TCP/UDS, which users can choose according to their needs.

UDP (User Datagram Protocol) is a connectionless transport protocol that does not provide reliability or flow control but offers lower latency and reduced network overhead. The UDP protocol is primarily used in scenarios requiring high real-time performance, such as live video streaming and online gaming.

TCP (Transmission Control Protocol) is a connection-oriented, reliable transport protocol. It provides reliable data transmission, flow control, congestion control, error detection, and traffic management, making it one of the most commonly used transport protocols on the internet.

UDS (Unix Domain Socket) is a mechanism for inter-process communication on the same computer. Unlike network sockets, UDS does not require a network protocol stack or network devices, enabling faster communication with lower latency and higher throughput.

The following is the class inheritance hierarchy for Socket provided by this library:

Hierarchy
 ResourceStreamingSocket
 │   ├TcpSocket
 │   └UnixSocket
 │
 ├DatagramSocket
 │   ├UdpSocket
 │   └UnixDatagramSocket
 │
 └ServerSocketTcpServerSocketUnixServerSocket

API List

Interfaces

Interface Name Functionality
DatagramSocket DatagramSocket is a socket for receiving and reading datagrams.
ServerSocket Provides the interface required for server-side Socket.
StreamingSocket A Socket operating in full-duplex streaming mode, capable of being read from and written to.

Classes

Class Name Functionality
IPAddress This class represents an Internet Protocol (IP) address.
IPPrefix This class represents an IP prefix (also known as an "IP subnet"), i.e., a contiguous block of IP addresses bounded by a power of two.
IPSocketAddress This class implements an IP protocol socket address (IP address + port number).
IPv4Address This class represents an Internet Protocol version 4 (IPv4) address.
IPv6Address This class represents an Internet Protocol version 6 (IPv6) address.
RawSocket RawSocket provides basic socket functionalities.
SocketAddress This class represents a protocol-independent socket address.
TcpServerSocket A server that listens for TCP connections.
TcpSocket A client that requests TCP connections.
UdpSocket Provides UDP datagram communication.
UnixDatagramSocket Provides host communication capabilities based on datagrams.
UnixServerSocket Provides a server for full-duplex streaming-based host communication.
UnixSocket Provides a client for full-duplex streaming-based host communication.
UnixSocketAddress This class implements a Unix Domain Socket address.

Enums

Enum Name Functionality
SocketNet Transport layer protocol types.

Structs

Struct Name Functionality
AddressFamily The address family is used to identify individual network address schemes or numbering plans in contexts where the use of individual addresses may be ambiguous.
OptionLevel Provides commonly used socket option levels.
OptionName Provides commonly used socket options.
ProtocolType Provides commonly used socket protocols and the functionality to construct socket protocols by specifying an Int32 value.
RawAddress Provides functionality for creating and retrieving communication addresses for RawSocket.
SocketDomain Provides commonly used socket communication domains and the functionality to construct socket communication domains by specifying an Int32 value.
SocketKeepAliveConfig TCP KeepAlive property configuration.
SocketOptions SocketOptions stores some parameter constants for setting socket options for subsequent calls.
SocketType Provides commonly used socket types and the functionality to construct socket types by specifying an Int32 value.

Exception Classes

Exception Class Name Functionality
SocketException Provides exception handling related to sockets.
SocketTimeoutException Provides exception handling related to character formatting.