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.
Parameters
| port | TCP port number to bind and listen on | |
| backlog | maximum 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.
Parameters
| listen-fd | listening 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.
Parameters
| host | IPv4 address string (e.g. "127.0.0.1") | |
| port | TCP 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.
Parameters
| fd | connected socket file descriptor | |
| data | pointer to the bytes to send | |
| len | number 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.
Parameters
| fd | connected socket file descriptor | |
| buf-size | maximum 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.
Parameters
| fd | socket file descriptor to close |
Since: Phase T24