For the latest stable version, please use Emilua API 0.10!

unix.stream_acceptor

local a = unix.stream_acceptor.new()
a:open()
a:bind(filesystem.path.new('/tmp/9Lq7BNBnBycd6nxy.socket'))
a:listen()

while true do
    local s = a:accept()
    spawn(function()
        my_client_handler(s)
    end)
end

Functions

new() → unix.stream_acceptor

new()                    (1)
new(fd: file_descriptor) (2)
1 Default constructor.
2 Converts a file descriptor into an unix.stream_acceptor object.

open(self)

Open the acceptor.

set_option(self, opt: string, val)

Set an option on the acceptor.

Currently available options are:

"enable_connection_aborted"

Check Boost.Asio documentation.

"debug"

Check Boost.Asio documentation.

get_option(self, opt: string) → value

Get an option from the acceptor.

Currently available options are:

"enable_connection_aborted"

Check Boost.Asio documentation.

"debug"

Check Boost.Asio documentation.

bind(self, pathname: filesystem.path)

Bind the acceptor to the given local endpoint.

listen(self [, backlog: integer])

Place the acceptor into the state where it will listen for new connections.

backlog is the maximum length of the queue of pending connections. If not provided, an implementation defined maximum length will be used.

accept(self) → unix.stream_socket

Initiate an accept operation and blocks current fiber until it completes or errs.

close(self)

Close the acceptor.

Any asynchronous accept operations will be cancelled immediately.

A subsequent call to open() is required before the acceptor can again be used to again perform socket accept operations.

cancel(self)

Cancel all asynchronous operations associated with the acceptor.

This function causes all outstanding asynchronous connect, send and receive operations to finish immediately, and the handlers for cancelled operations will be passed the boost::asio::error::operation_aborted error.

assign(self, fd: file_descriptor)

Assign an existing native acceptor to self.

release(self) → file_descriptor

Release ownership of the native descriptor implementation.

This function causes all outstanding asynchronous accept operations to finish immediately, and the handlers for cancelled operations will be passed the boost::asio::error::operation_aborted error. Ownership of the native acceptor is then transferred to the caller.

Properties

is_open: boolean

Whether the acceptor is open.

local_path: filesystem.path

The local address of the acceptor.