std.socket

Socket primitives.

Public Imports

core.sys.windows.winsock2
public import core.sys.windows.winsock2;
core.sys.posix.netinet.in_
public import core.sys.posix.netinet.in_;

Members

Classes

Address
class Address

Address is an abstract class for representing a socket addresses.

AddressException
class AddressException

Class for exceptions thrown from an Address.

HostException
class HostException

Class for exceptions thrown from an InternetHost.

Internet6Address
class Internet6Address

Internet6Address encapsulates an IPv6 (Internet Protocol version 6) socket address.

InternetAddress
class InternetAddress

InternetAddress encapsulates an IPv4 (Internet Protocol version 4) socket address.

InternetHost
class InternetHost

InternetHost is a class for resolving IPv4 addresses.

Protocol
class Protocol

Protocol is a class for retrieving protocol information.

Service
class Service

Service is a class for retrieving service information.

Socket
class Socket

Socket is a class that creates a network communication endpoint using the Berkeley sockets interface.

SocketAcceptException
class SocketAcceptException

Class for exceptions thrown by Socket.accept.

SocketException
class SocketException

Base exception thrown by std.socket.

SocketFeatureException
class SocketFeatureException

Socket exceptions representing attempts to use network capabilities not available on the current system.

SocketOSException
class SocketOSException

Socket exceptions representing network errors reported by the operating system.

SocketParameterException
class SocketParameterException

Socket exceptions representing invalid parameters specified by user code.

SocketSet
class SocketSet

A collection of sockets for use with Socket.select.

TcpSocket
class TcpSocket

TcpSocket is a shortcut class for a TCP Socket.

UdpSocket
class UdpSocket

UdpSocket is a shortcut class for a UDP Socket.

UnixAddress
class 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
class UnknownAddress

UnknownAddress encapsulates an unknown socket address.

UnknownAddressReference
class UnknownAddressReference

UnknownAddressReference encapsulates a reference to an arbitrary socket address.

Enums

AddressFamily
enum AddressFamily

The communication domain used to resolve an address.

AddressInfoFlags
enum AddressInfoFlags

A subset of flags supported on all platforms with getaddrinfo. Specifies option flags for getAddressInfo.

ProtocolType
enum ProtocolType

Protocol

SocketFlags
enum SocketFlags

Flags may be OR'ed together:

SocketOption
enum SocketOption

Specifies a socket option:

SocketOptionLevel
enum SocketOptionLevel

The level at which a socket option is defined:

SocketShutdown
enum SocketShutdown

How a socket is shutdown:

SocketType
enum SocketType

Communication semantics

Functions

getAddress
Address[] getAddress(const(char)[] hostname, const(char)[] service)
Address[] getAddress(const(char)[] hostname, ushort port)

Provides _protocol-independent translation from host names to socket addresses. Uses getAddressInfo if the current system supports it, and InternetHost otherwise.

getAddressInfo
AddressInfo[] getAddressInfo(const(char)[] node, T 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.

parseAddress
Address parseAddress(const(char)[] hostaddr, const(char)[] service)
Address parseAddress(const(char)[] hostaddr, ushort port)

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
Socket[2] socketPair()

Creates a pair of connected sockets.

wouldHaveBlocked
bool wouldHaveBlocked()

Properties

lastSocketError
string lastSocketError [@property getter]

Retrieve the error message for the most recently encountered network error.

Structs

AddressInfo
struct AddressInfo

Holds information about a socket _address retrieved by getAddressInfo.

Linger
struct Linger

Linger information for use with SocketOption.LINGER.

TimeVal
struct TimeVal

Duration timeout value.

Examples

See $(SAMPLESRC listener.d) and $(SAMPLESRC htmlget.d)

Meta