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

## SYNOPSIS

flag = handle:bind(local_address, local_port)

## DESCRIPTION

This assigns a local address to a socket.

local_address must either be the IP address of one of the local network interfaces, or nil to indicate ANY interface.

local_port is the local port number to be attached to that socket, in the range of 1 .. 65535.

## RETURN VALUE

On success, returns true. On failure or end-of-file, 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:getsockopt, rawio.ifconfig, rawio.interfaces, rawio:listen, rawio:recvfrom, rawio:sendto, rawio:setsockopt, rawio:shutdown, rawio.socket