tango.net.device.Berkeley

enum
enum SocketOption
enum SocketOptionLevel
enum SocketType
STREAM
sequential, reliable
DGRAM
connectionless unreliable, max length
SEQPACKET
sequential, reliable, max length
enum ProtocolType
IP
default internet protocol (probably 4 for compatibility)
IPV4
internet protocol version 4
IPV6
internet protocol version 6
ICMP
internet control message protocol
IGMP
internet group management protocol
TCP
transmission control protocol
PUP
PARC universal packet protocol
UDP
user datagram protocol
IDP
Xerox NS protocol
enum AddressFamily
enum SocketShutdown
enum SocketFlags
OOB
out of band
PEEK
only for receiving
DONTROUTE
only for sending
NOSIGNAL
inhibit signals
int getaddrinfo(const(char)* node, const(char)* service, Address.addrinfo* hints, Address.addrinfo** res) [package, extern(C)]
Given node and service, which identify an Internet host and a service, getaddrinfo() returns one or more addrinfo structures, each of which contains an Internet address that can be specified in a call to bind or connect. The getaddrinfo() function combines the functionality provided by the getservbyname and getservbyport functions into a single interface, but unlike the latter functions, getaddrinfo() is reentrant and allows programs to eliminate IPv4-versus-IPv6 dependencies. (C) MAN
void freeaddrinfo(Address.addrinfo* res) [package, extern(C)]
The freeaddrinfo() function frees the memory that was allocated for the dynamically allocated linked list res. (C) MAN
int getnameinfo(Address.sockaddr* sa, int salen, char* host, int hostlen, char* serv, int servlen, int flags) [package, extern(C)]
The getnameinfo() function is the inverse of getaddrinfo: it converts a socket address to a corresponding host and service, in a protocol-independent manner. It combines the functionality of gethostbyaddr and getservbyport, but unlike those functions, getaddrinfo is reentrant and allows programs to eliminate IPv4-versus-IPv6 dependencies. (C) MAN
const(char)* gai_strerror(int errcode) [package, extern(C)]
The gai_strerror function translates error codes of getaddrinfo, freeaddrinfo and getnameinfo to a human readable string, suitable for error reporting. (C) MAN
struct Berkeley [public]
void open(AddressFamily family, SocketType type, ProtocolType protocol, bool create = true)
Configure this instance
void reopen(socket_t sock = init)
Open/reopen a native socket for this instance
void detach()
calling shutdown() before this is recommended for connection- oriented sockets
socket_t handle() [@property, const]
Return the underlying OS handle of this Conduit
int error() [@property, const]
Return socket error status
int lastError() [@property, static]
Return the last error
bool isAlive() [@property, const]
Is this socket still alive? A closed socket is considered to be dead, but a shutdown socket is still alive.
AddressFamily addressFamily() [@property]
Berkeley* bind(Address addr)
Berkeley* connect(Address to)
Berkeley* listen(int backlog)
need to bind() first
void accept(ref Berkeley target)
need to bind() first
Berkeley* shutdown(SocketShutdown how)
The shutdown function shuts down the connection of the socket. Depending on the argument value, it will:
- stop receiving data for this socket. If further data arrives, it is rejected.

- stop trying to transmit data from this socket. Also discards any data waiting to be sent. Stop looking for acknowledgement of data already sent; don't retransmit if any data is lost.
Berkeley* linger(int period) [@property]
set linger timeout
Berkeley* addressReuse(bool enabled) [@property]
enable/disable address reuse
Berkeley* noDelay(bool enabled) [@property]
enable/disable noDelay option (nagle)
void joinGroup(IPv4Address address, bool onOff)
Helper function to handle the adding and dropping of group membership.
Address newFamilyObject() [const]
char[] hostName() [@property, static]
return the hostname
uint hostAddress() [@property, static]
return the default host address (IPv4)
Address remoteAddress() [@property, const]
return the remote address of the current connection (IPv4)
Address localAddress() [@property, const]
return the local address of the current connection (IPv4)
int send(const(void)[] buf, SocketFlags flags = NONE) [const]
Send data on the connection. Returns the number of bytes actually sent, or ERROR on failure. If the socket is blocking and there is no buffer space left, send waits.
Returns number of bytes actually sent, or -1 on error
int sendTo(const(void)[] buf, SocketFlags flags, Address to) [const]
int sendTo(const(void)[] buf, Address to) [const]
Send data to a specific destination Address. If the destination address is not specified, a connection must have been made and that address is used. If the socket is blocking and there is no buffer space left, sendTo waits.
int sendTo(const(void)[] buf, SocketFlags flags = NONE) [const]
ditto - assumes you connect()ed
int receive(void[] buf, SocketFlags flags = NONE) [const]
Receive data on the connection. Returns the number of bytes actually received, 0 if the remote side has closed the connection, or ERROR on failure. If the socket is blocking, receive waits until there is data to be received.
Returns number of bytes actually received, 0 on connection closure, or -1 on error
int receiveFrom(void[] buf, SocketFlags flags, Address from) [const]
int receiveFrom(void[] buf, Address from) [const]
Receive data and get the remote endpoint Address. Returns the number of bytes actually received, 0 if the remote side has closed the connection, or ERROR on failure. If the socket is blocking, receiveFrom waits until there is data to be received.
int receiveFrom(void[] buf, SocketFlags flags = NONE) [const]
ditto - assumes you connect()ed
int getOption(SocketOptionLevel level, SocketOption option, void[] result) [const]
returns the length, in bytes, of the actual result - very different from getsockopt()
Berkeley* setOption(SocketOptionLevel level, SocketOption option, const(void)[] value)
bool blocking() [@property, const]
getter
void blocking(bool yes) [@property]
setter
void exception(immutable(char)[] msg) [static]
void badArg(immutable(char)[] msg) [protected, static]
class Address [public, abstract]
void exception(immutable(char)[] msg) [static]

Tango:

added this common function
Address create(sockaddr* sa) [static]
Address factory
Address resolve(const(char)[] host, const(char)[] service = null, AddressFamily af = UNSPEC, AIFlags flags = cast(AIFlags)0) [static]
Address resolve(const(char)[] host, ushort port, AddressFamily af = UNSPEC, AIFlags flags = cast(AIFlags)0) [static]
Address[] resolveAll(const(char)[] host, const(char)[] service = null, AddressFamily af = UNSPEC, AIFlags flags = cast(AIFlags)0) [static]
Address[] resolveAll(const(char)[] host, ushort port, AddressFamily af = UNSPEC, AIFlags flags = cast(AIFlags)0) [static]
Address passive(const(char)[] service, AddressFamily af = UNSPEC, AIFlags flags = cast(AIFlags)0) [static]
Address passive(ushort port, AddressFamily af = UNSPEC, AIFlags flags = cast(AIFlags)0) [static]
char[] toAddrString() [@property]
char[] toPortString() [@property]
string toString() [override]
AddressFamily addressFamily() [@property]
class UnknownAddress : Address [public]
sockaddr* name() [@property, override]
int nameLen() [@property, override, const]
AddressFamily addressFamily() [@property, override]
string toString() [override]
class IPv4Address : Address [public]
enum
struct sockaddr_in
this() [protected]
this(ushort port)
this(uint addr, ushort port)
this(const(char)[] addr, ushort port = PORT_ANY)
-port- can be PORT_ANY -addr- is an IP address or host name
this(sockaddr* addr)
sockaddr* name() [@property, override]
int nameLen() [@property, override, const]
AddressFamily addressFamily() [@property, override]
ushort port() [@property, const]
uint addr() [@property, const]
char[] toAddrString() [@property, override, const]
char[] toPortString() [@property, override, const]
string toString() [override]
uint parse(const(char)[] addr) [static]
-addr- is an IP address in the format "a.b.c.d" returns ADDR_NONE on failure
class IPv6Address : Address
IPv6 is the next-generation Internet Protocol version designated as the successor to IPv4, the first implementation used in the Internet that is still in dominant use currently.
More information: http://ipv6.com/

IPv6 supports 128-bit address space as opposed to 32-bit address space of IPv4.

IPv6 is written as 8 blocks of 4 octal digits (16 bit) separated by a colon (":"). Zero block can be replaced by "::".

For example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
0000:0000:0000:0000:0000:0000:0000:0001
is equal
::0001
is equal
::1
is analogue IPv4 127.0.0.1

0000:0000:0000:0000:0000:0000:0000:0000
is equal
::
is analogue IPv4 0.0.0.0

2001:cdba:0000:0000:0000:0000:3257:9652
is equal
2001:cdba::3257:9652

IPv4 address can be submitted through IPv6 as ::ffff:xx.xx.xx.xx,
where xx.xx.xx.xx 32-bit IPv4 addresses.

::ffff:51b0:ec6d
is equal
::ffff:81.176.236.109
is analogue IPv4 81.176.236.109

The URL for the IPv6 address will be of the form:
http://[2001:cdba:0000:0000:0000:0000:3257:9652]/

If needed to specify a port, it will be listed after the
closing square bracket followed by a colon.

http://[2001:cdba:0000:0000:0000:0000:3257:9652]:8080/
address: "2001:cdba:0000:0000:0000:0000:3257:9652"
port: 8080

IPv6Address can be used as well as IPv4Address.

scope addr = new IPv6Address(8080);
address: "::"
port: 8080

scope addr_2 = new IPv6Address("::1", 8081);
address: "::1"
port: 8081

scope addr_3 = new IPv6Address("::1");
address: "::1"
port: PORT_ANY

Also in the IPv6Address constructor can specify the service name
or port as string

scope addr_3 = new IPv6Address("::", "ssh");
address: "::"
port: 22 (ssh service port)

scope addr_4 = new IPv6Address("::", "8080");
address: "::"
port: 8080
struct sockaddr_in6 [protected]
this() [protected]
this(sockaddr* sa) [protected]
sockaddr* name() [@property, override]
int nameLen() [@property, override, const]
AddressFamily addressFamily() [@property, override]
ushort port() [@property, const]
this(int port) [public]
Create IPv6Address with zero address
this(const(char)[] addr, int port = PORT_ANY) [public]
-port- can be PORT_ANY -addr- is an IP address or host name
this(const(char)[] addr, const(char)[] service) [public]
-service- can be a port number or service name -addr- is an IP address or host name
ubyte[] addr() [@property]
char[] toAddrString() [@property, override, const]
char[] toPortString() [@property, override, const]
string toString() [override]
class NetHost [public]
struct hostent
void validHostent(hostent* he) [protected]
void populate(hostent* he)
bool getHostByName(const(char)[] name)
bool getHostByAddr(uint addr)
bool getHostByAddr(const(char)[] addr)
class SocketSet [public]
a set of sockets for Berkeley.select()
int select(SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, timeval* tv) [static]
SocketSet's are updated to include only those sockets which an event occured.
Returns the number of events, 0 on timeout, or -1 on error

for a connect()ing socket, writeability means connected for a listen()ing socket, readability means listening

Winsock:

possibly internally limited to 64 sockets per set
int select(SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, long microseconds) [static]
select with specified timeout
int select(SocketSet checkRead, SocketSet checkWrite, SocketSet checkError) [static]
select with maximum timeout