Create a new socket.
Address family, e.g. defines.AF_INET
Socket type, e.g. defines.SOCK_STREAM
Protocol, usually 0 for auto-select
ReadonlyfilenoThe underlying file descriptor number.
ReadonlyinfoType/domain/protocol info queried from the OS.
Readonlypollingtrue while a poll is active.
Accept an incoming connection.
The returned socket has a _sockaddr property with the peer address bytes.
Bind to a local address (use create_sockaddr_inet to build the buffer).
Close the socket. Cannot be called from within a poll callback.
Connect to a remote address.
On UDP sockets this only sets the default destination (no handshake),
enabling send to work without an explicit address — a portable
alternative to sendto.
Get a socket option as raw bytes.
Optionaloptlen: numberExpected buffer size (defaults to sizeof(sockaddr_storage))
Mark socket as passive (server).
Start polling for I/O readiness via libuv.
The callback receives (status: number, events: number) where events
is a bitmask of UvPollEventBits.
Stop polling. Cannot be called from within the poll callback.
Receive up to count bytes.
Returns null on EOF / graceful peer close.
Optionalflags: numberOptional recv flags (e.g. MSG_PEEK)
Receive a datagram with ancillary data. POSIX only.
Maximum payload size
Optionalcontrolsize: numberMaximum ancillary data size (omit if not needed)
Send bytes. Returns the number of bytes actually sent.
Optionalflags: numberOptional send flags (e.g. MSG_DONTWAIT)
Send a message with optional address and ancillary data. POSIX only.
Destination address bytes, or undefined for connected sockets
Ancillary (cmsg) data, or undefined
Send flags
One or more data buffers (scatter-gather)
Shut down one or both directions.
0 = RD, 1 = WR, 2 = RDWR
Thin wrapper around a POSIX/Winsock socket file descriptor. All operations are synchronous and non-blocking behaviour must be arranged by the caller (e.g. via PosixSocket.poll).
Example: TCP server
Example: UDP broadcast (Wake-on-LAN)