View source code
Display the source code in std/socket.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Module std.socket

Socket primitives.

Example

See /dmd/compiler/samples/listener.d and /dmd/compiler/samples/htmlget.d

Functions

NameDescription
getAddress(hostname, service) Provides protocol-independent translation from host names to socket addresses. Uses getAddressInfo if the current system supports it, and InternetHost otherwise.
getAddressInfo(node, options) Provides protocol-independent translation from host names to socket addresses. If advanced functionality is not required, consider using getAddress for compatibility with older systems.
lastSocketError() Returns the error message of the most recently encountered network error.
parseAddress(hostaddr, service) Provides protocol-independent parsing of network addresses. Does not attempt name resolution. Uses getAddressInfo with AddressInfoFlags.NUMERICHOST if the current system supports it, and InternetAddress otherwise.
socketPair() Creates a pair of connected sockets.
wouldHaveBlocked()

Classes

NameDescription
Address Abstract class for representing a socket address.
AddressException Class for exceptions thrown from an Address.
HostException Class for exceptions thrown from an InternetHost.
Internet6Address Encapsulates an IPv6 (Internet Protocol version 6) socket address.
InternetAddress Encapsulates an IPv4 (Internet Protocol version 4) socket address.
InternetHost Class for resolving IPv4 addresses.
Protocol Class for retrieving protocol information.
Service Class for retrieving service information.
Socket Class that creates a network communication endpoint using the Berkeley sockets interface.
SocketAcceptException Exception thrown by Socket.accept.
SocketException Base exception thrown by std.socket.
SocketFeatureException Socket exception representing attempts to use network capabilities not available on the current system.
SocketOSException Socket exception representing network errors reported by the operating system.
SocketParameterException Socket exception representing invalid parameters specified by user code.
SocketSet A collection of sockets for use with Socket.select.
TcpSocket Shortcut class for a TCP Socket.
UdpSocket Shortcut class for a UDP Socket.
UnixAddress Encapsulates an address for a Unix domain socket (AF_UNIX), i.e. a socket bound to a path name in the file system. Available only on supported systems.
UnknownAddress Encapsulates an unknown socket address.
UnknownAddressReference Encapsulates a reference to an arbitrary socket address.

Structs

NameDescription
AddressInfo Holds information about a socket address retrieved by getAddressInfo.
Linger Linger information for use with SocketOption.LINGER.
TimeVal Duration timeout value.

Enums

NameDescription
AddressFamily The communication domain used to resolve an address.
AddressInfoFlags A subset of flags supported on all platforms with getaddrinfo. Specifies option flags for getAddressInfo.
ProtocolType Protocol
SocketFlags Socket flags that may be OR'ed together:
SocketOption Specifies a socket option:
SocketOptionLevel The level at which a socket option is defined:
SocketShutdown How a socket is shutdown:
SocketType Communication semantics

Authors

Christopher E. Miller, David Nadlinger, Vladimir Panteleev

License

Boost License 1.0.