IIPSocket

IP socket base class

Constructors

this
this(bool is_ipv6, socklen_t in_addrlen)

public const socklen_t in_addrlen; Constructor.

Members

Aliases

SocketFlags
alias SocketFlags = .SocketFlags

Flags supported by accept4().

TcpOptions
alias TcpOptions = .TcpOptions
Undocumented in source.
socket
alias socket = ISocket.socket
Undocumented in source.

Functions

is_ipv6
bool is_ipv6()

true for IPv6, false for IPv4.

socket
int socket(int type, int protocol)

Creates an IP socket endpoint for communication and sets this.fd to the corresponding file descriptor.

tcpSocket
int tcpSocket(bool nonblocking)

Calls socket() to create a TCP/IP socket, setting this.fd to the file descriptor.

Inherited Members

From ISocket

SocketFlags
alias SocketFlags = .SocketFlags

Flags supported by accept4().

fd
int fd;

File descriptor. Set by socket()/accept() and reset by close() and clear(). Should be modified otherwise only in special situations.

close_in_destructor
bool close_in_destructor;

If true, the destructor will call close(). Enabled by socket()/accept() on success, disabled by close() and socket()/accept() on failure. Should be modified otherwise only in special situations.

suppress_sigpipe
bool suppress_sigpipe;

If true, send() and therefore write() are requested not to send SIGPIPE on errors when this socket is stream oriented (e.g. TCP) and the other end breaks the connection.

in_addrlen
socklen_t in_addrlen;

Address struct (sin_addr/sin6_addr) length.

~this
~this()

Destructor. Calls close() if indicated by close_in_destructor.

fileHandle
Handle fileHandle()

Required by ISelectable.

error
int error()

Calls getsockopt(SOL_SOCKET, SO_ERROR) to obtain the current error code for this socket.

error
int error(ISelectable socket)

Calls getsockopt(SOL_SOCKET, SO_ERROR) to obtain the current error code for the socket referred to by fd.

socket
int socket(int domain, int type, int protocol)

Creates a socket endpoint for communication and sets this.fd to the corresponding file descriptor.

bind
int bind(sockaddr* local_address)

Assigns a local address to this socket. This socket needs to have been created by socket().

accept
int accept(ISelectable listening_socket, sockaddr* remote_address, socklen_t addrlen, SocketFlags flags)

Accepts a connection from a listening socket and sets this.fd to the accepted socket file descriptor.

accept
int accept(ISelectable listening_socket, SocketFlags flags)

Accepts a connection from a listening socket and sets this.fd to the accepted socket file descriptor.

accept
int accept(ISelectable listening_socket, bool nonblocking)

Accepts a connection from a listening socket and sets this.fd to the accepted socket file descriptor.

connect
int connect(sockaddr* remote_address)

Connects this socket the specified address and port.

listen
int listen(int backlog)

listen() marks this socket as a passive socket, that is, as a socket that will be used to accept incoming connection requests using accept().

shutdown
int shutdown(int how)

The shutdown() call causes all or part of a full-duplex connection on the socket to be shut down.

getsockopt
ssize_t getsockopt(int level, int optname, void[] dst)

Obtains the value of a socket option, writing the value data to dst.

getsockoptVal
ssize_t getsockoptVal(int level, int optname, T val)

Calls getsockopt() to obtain the value of a socket option.

setsockopt
int setsockopt(int level, int optname, const(void)[] src)

Sets the value of a socket option, using the value data in src. The actual value data type and length depends on the particular option.

setsockoptVal
int setsockoptVal(int level, int optname, T val)

Calls setsockopt() to sets the value of a socket option to val.

write
ssize_t write(const(void)[] src)

Calls send() to send as many src bytes as possible.

send
ssize_t send(const(void)[] src, int flags)

Sends as many src bytes as possible to the remote.

recv
ssize_t recv(void[] dst, int flags)

Receives dst.length bytes from the remote but at most as possible with one attempt.

getsockname
int getsockname(sockaddr* local_address, socklen_t addrlen)

Obtains the local socket address.

getpeername
int getpeername(sockaddr* remote_address, socklen_t addrlen)

Obtains the remote socket address.

close
int close()

Closes the socket and resets the file descriptor, address and port.

clear
void clear()

Resets the file descriptor, address and port. Called from close(), should be called otherwise only in special situations.

formatInfo
void formatInfo(char[] buf, bool io_error)

Formats information about the socket into the provided buffer.

Meta