tur/async_socket

stdlib/async_socket.tur
defn

async-socket-listen

(async-socket-listen [port :int backlog :int] :int)

create a non-blocking TCP listening socket on the given port.

portTCP port number to bind and listen on
backlogmaximum length of the pending connection queue

Since: Phase T24

defn

async-socket-accept

(async-socket-accept [listen-fd :int] :int)

accept an incoming connection, parking the fiber until one arrives.

listen-fdlistening file descriptor returned by async-socket-listen

Since: Phase T24

defn

async-socket-connect

(async-socket-connect [host :cstr port :int] :int)

connect to a TCP server at host:port, parking the fiber until complete.

hostIPv4 address string (e.g. "127.0.0.1")
portTCP port number to connect to

Since: Phase T24

defn

async-socket-send

(async-socket-send [fd :int data :cstr len :int] :int)

send data on a connected socket, parking the fiber on EAGAIN.

fdconnected socket file descriptor
datapointer to the bytes to send
lennumber of bytes to send

Since: Phase T24

defn

async-socket-recv

(async-socket-recv [fd :int buf-size :int] :int)

receive up to buf-size bytes from a connected socket.

fdconnected socket file descriptor
buf-sizemaximum number of bytes to receive

Since: Phase T24

defn

async-socket-recv-buf

(async-socket-recv-buf :ptr<void>)

retrieve the buffer pointer from the last async-socket-recv call.

Since: Phase T24

defn

async-socket-recv-len

(async-socket-recv-len :int)

retrieve the byte count from the last async-socket-recv call.

Since: Phase T24

defn

async-socket-close

(async-socket-close [fd :int] :nil)

close a socket and unregister it from IO polling.

fdsocket file descriptor to close

Since: Phase T24