Home Contents | # rawio:listen | Rawio | Core4 Lua Event System

## SYNOPSIS

flag = handle:listen([backlog])

## DESCRIPTION

Mark the socket referred to by handle as a passive or server socket. The socket can now be used to accept incoming connection requests by using rawio:accept(). The socket must have been attached to a local address and port number by calling rawio:bind() before it can be set to listen.

The optional backlog parameter determines how many connection requests are buffered by the operating system. If more connection requests arrive which the application hasn't accepted yet, the kernel ignores them. Usually clients will retry the connection request later, when they may succeed. The default is four.

## RETURN VALUE

On success, returns true. On failure, returns nil. In case of an error, the error can be retrieved using rawio:lastError().

## EXAMPLE

A webserver's initialization might look like this:
> > >
srv = rawio.socket("TCP") srv:bind(nil, 80) srv:listen()

## SEE ALSO

rawio:accept, rawio:bind, rawio:getsockopt, rawio.ifconfig, rawio.interfaces, rawio:recvfrom, rawio:sendto, rawio:setsockopt, rawio:shutdown, rawio.socket