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.


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


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() Retrieve the error message for 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.


Address Address is an abstract class for representing a socket addresses.
AddressException Class for exceptions thrown from an Address.
HostException Class for exceptions thrown from an InternetHost.
Internet6Address Internet6Address encapsulates an IPv6 (Internet Protocol version 6) socket address.
InternetAddress InternetAddress encapsulates an IPv4 (Internet Protocol version 4) socket address.
InternetHost InternetHost is a class for resolving IPv4 addresses.
Protocol Protocol is a class for retrieving protocol information.
Service Service is a class for retrieving service information.
Socket Socket is a class that creates a network communication endpoint using the Berkeley sockets interface.
SocketAcceptException Class for exceptions thrown by Socket.accept.
SocketException Base exception thrown by std.socket.
SocketFeatureException Socket exceptions representing attempts to use network capabilities not available on the current system.
SocketOSException Socket exceptions representing network errors reported by the operating system.
SocketParameterException Socket exceptions representing invalid parameters specified by user code.
SocketSet A collection of sockets for use with
TcpSocket TcpSocket is a shortcut class for a TCP Socket.
UdpSocket UdpSocket is a shortcut class for a UDP Socket.
UnixAddress 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 UnknownAddress encapsulates an unknown socket address.
UnknownAddressReference UnknownAddressReference encapsulates a reference to an arbitrary socket address.


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


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 Flags 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


Christopher E. Miller, David Nadlinger, Vladimir Panteleev


Boost License 1.0.