Function ConnectedSocket.listen
Create a stream socket and bind, as a listening server, to the address supplied
static ConnectedSocket listen
(
SockAddr sa,
bool reuseAddr = false
) @nogc @trusted;
ConnectedSocket listen(SA)
(
SA sa,
bool reuseAddr = false
) @nogc @trusted
if (is(typeof(SockAddr(sa)) == SockAddr));
This creates a TCP socket (or equivalent for the address family). It binds it to the designated address specified in sa, and puts it in listening mode.
Parameters
Name | Description |
---|---|
sa | a socket address for the server to listen on. The second form is for passing protocol specific addresses
(SockAddrIPv4 , SockAddrIPv6 , SockAddrUnix ). |
reuseAddr | Whether to set the SO_REUSEADDR socket option |
Returns
Returns the listening socket.
Throws
ErrnoException if the connection fails (e.g. - EADDRINUSE if binding to a used port). Also throws this if one of the system calls fails.