Linux IPv4 socket declarations for addresses, address-resolution records, raw socket options, connection lifecycle, byte-order conversion, and address resolution.
AF_INET: IPv4 address family.SOCK_STREAM: stream socket kind.IPPROTO_TCP: TCP protocol selector.SOL_SOCKET, SO_ERROR, SO_REUSEADDR, and TCP_NODELAY: socket and TCP option identifiers.SHUT_WR: shutdown selector for the write direction.F_GETFL and F_SETFL: file-status command identifiers commonly used together with fcntl.INADDR_ANY: wildcard IPv4 address constant.INVALID_SOCKET: invalid descriptor marker.MSG_NOSIGNAL: send flag that suppresses signal delivery.SOMAXCONN: listen-backlog upper bound constant."linux/socket" use
"control" use
{} () {} [
AF_INET printStack _:;
SOCK_STREAM printStack _:;
SHUT_WR printStack _:;
INADDR_ANY printStack _:;
] "main" exportFunction
2
1
1
0n32
addrinfo: address-resolution result node with family, type, protocol, length, and pointer-shaped fields.in_addr: IPv4 address storage schema.sockaddr: generic socket-address wrapper with one family field and raw address bytes.sockaddr_in: IPv4 socket-address schema with family, port, address, and zero padding.socklen_t: socket-length schema."linux/socket" use
"control" use
{} () {} [
sockaddr_in fieldCount printStack _:;
addrinfo 0 fieldName printStack _:;
] "main" exportFunction
4
"ai_flags"
socket and accept return plain Int32 descriptors.close and fcntl.sockaddr_in.sin_port and sockaddr_in.sin_addr are passed to imported socket functions in network byte order.htons and htonl convert host-order port and IPv4 values before those fields are assigned, and ntohl converts IPv4 addresses back to host order.getaddrinfo consumes raw zero-terminated node and service pointers together with one borrowed addrinfo Cref hint object.getaddrinfo writes the head pointer of the returned addrinfo list through res, and freeaddrinfo releases that whole linked list.accept.addr and accept.addrlen are caller-owned writable storage. accept may write the peer address into addr and the actual byte size into addrlen.bind.addr and connect.addr are borrowed read-only address references whose byte size is supplied by the corresponding addrlen argument.recv.buf and send.buf are raw byte pointers, and len is the requested or transferred byte count.setsockopt.option_value is one borrowed raw pointer to caller-owned option bytes, and option_len is that byte count.getsockopt.option_value and getsockopt.option_len are caller-owned writable storage for returned option bytes and the resulting byte count.socket and accept report their result through the returned descriptor value, with INVALID_SOCKET as the invalid-descriptor sentinel.bind, connect, listen, shutdown, setsockopt, and getsockopt return Int32 status results.send and recv return Intx transfer counts. -1ix reports failure, and recv returning 0ix on a stream socket reports peer closure.getaddrinfo returns one Int32 result code and writes the head pointer of the result list through res.socket and accept results are descriptors released with close when they are no longer needed.freeaddrinfo releases the linked address-resolution result list returned by getaddrinfo.getaddrinfo is provided separately.socket, then connect, then send and recv, optionally followed by shutdown.socket, optional setsockopt, bind, listen, and then accept.send, recv, and shutdown operations as directly connected descriptors.accept, bind, connect, listen, shutdown, and socket: socket lifecycle and connection operations.recv and send: stream receive and send operations.setsockopt and getsockopt: socket option access.getaddrinfo and freeaddrinfo: address-resolution helpers.htonl, htons, and ntohl: host/network byte-order conversions.Printing imported names during compilation shows the exact imported signatures.
"linux/socket" use
"control" use
{} Int32 {} [
@getaddrinfo printStack _:;
@recv printStack _:;
@socket printStack _:;
0
] "main" exportFunction
{node: Natx; service: Natx; hints: {ai_flags: Int32; ai_family: Int32; ai_socktype: Int32; ai_protocol: Int32; ai_addrlen: Natx; ai_addr: Natx; ai_canonname: Natx; ai_next: Natx;} Cref; res: Natx;} Int32 {convention: "";} codeRef
{sockfd: Int32; buf: Natx; len: Natx; flags: Int32;} Intx {convention: "";} codeRef
{domain: Int32; type: Int32; protocol: Int32;} Int32 {convention: "";} codeRef
Byte-order helpers can be demonstrated without external networking state.
"linux/socket" use
"String" use
"control" use
{} Int32 {} [
(0x01020304n32 htonl ntohl 0x01020304n32 = toString LF) printList
0
] "main" exportFunction
TRUE
"linux/socket" use
"linux/posix" use
"String" use
"control" use
{} Int32 {} [
sock: AF_INET SOCK_STREAM IPPROTO_TCP socket;
("created=" sock 0 < ~ LF
"close=" sock close 0 = LF) printList
0
] "main" exportFunction
created=TRUE
close=TRUE