.TH "ws.h" 3 "axil" \" -*- nroff -*- .ad l .nh .SH NAME ws.h \- WebSocket framing on top of the axil I/O table\&. .SH SYNOPSIS .br .PP \fR#include \fP .br \fR#include \fP .br .SS "Functions" .in +1c .ti -1c .RI "int \fBws_init\fP (\fBsocket_t\fP fd, char *buf)" .br .RI "Initialize WebSocket framing on a descriptor\&. " .ti -1c .RI "void \fBws_close\fP (\fBsocket_t\fP fd)" .br .RI "Close a WebSocket session and tear down its framing state\&. " .ti -1c .RI "\fBio_ssize_t\fP \fBws_read\fP (\fBsocket_t\fP fd, void *data, \fBio_size_t\fP len, int flags)" .br .RI "Framed read hook installed into the I/O table\&. " .ti -1c .RI "\fBio_ssize_t\fP \fBws_write\fP (\fBsocket_t\fP fd, void *data, \fBio_size_t\fP n, int flags)" .br .RI "Framed write hook installed into the I/O table\&. " .ti -1c .RI "int \fBws_dprintf\fP (\fBsocket_t\fP fd, const char *fmt, va_list ap)" .br .RI "Write a formatted string over a WS frame (va_list form)\&. " .ti -1c .RI "int \fBws_printf\fP (\fBsocket_t\fP fd, const char *fmt,\&.\&.\&.)" .br .RI "Write a formatted string over a WS frame\&. " .in -1c .SH "Detailed Description" .PP WebSocket framing on top of the axil I/O table\&. Handles handshake buffers, close, and framed read/write dispatch through the io[fd] slots\&. .SH "Function Documentation" .PP .SS "void ws_close (\fBsocket_t\fP fd)" .PP Close a WebSocket session and tear down its framing state\&. .PP \fBParameters\fP .RS 4 \fIfd\fP Socket descriptor\&. .RE .PP .SS "int ws_dprintf (\fBsocket_t\fP fd, const char * fmt, va_list ap)" .PP Write a formatted string over a WS frame (va_list form)\&. .PP \fBParameters\fP .RS 4 \fIfd\fP Socket descriptor\&. .br \fIfmt\fP Format string\&. .br \fIap\fP Argument list\&. .RE .PP \fBReturns\fP .RS 4 0 on success, -1 on error\&. .RE .PP .SS "int ws_init (\fBsocket_t\fP fd, char * buf)" .PP Initialize WebSocket framing on a descriptor\&. .PP \fBParameters\fP .RS 4 \fIfd\fP Socket descriptor\&. .br \fIbuf\fP Handshake buffer (consumed by the handshake)\&. .RE .PP \fBReturns\fP .RS 4 0 on success, -1 on failure\&. .RE .PP .SS "int ws_printf (\fBsocket_t\fP fd, const char * fmt, \&.\&.\&.)" .PP Write a formatted string over a WS frame\&. .PP \fBParameters\fP .RS 4 \fIfd\fP Socket descriptor\&. .br \fIfmt\fP Format string\&. .RE .PP \fBReturns\fP .RS 4 0 on success, -1 on error\&. .RE .PP .SS "\fBio_ssize_t\fP ws_read (\fBsocket_t\fP fd, void * data, \fBio_size_t\fP len, int flags)" .PP Framed read hook installed into the I/O table\&. .PP \fBParameters\fP .RS 4 \fIfd\fP Socket descriptor\&. .br \fIdata\fP Destination buffer\&. .br \fIlen\fP Requested byte count\&. Must be at least 1 whenever \fRdata\fP is non-NULL: a zero-length destination is refused with -1 and \fRerrno\fP EMSGSIZE, since it is the one value that cannot describe any buffer at all\&. \fRdata == NULL\fP discards the frame whatever \fRlen\fP is\&. The frame's NUL terminator needs one of these bytes, so a payload is only returned when it fits in \fRlen - 1\fP\&. .br \fIflags\fP Operation flags\&. .RE .PP \fBReturns\fP .RS 4 Bytes read (NUL-terminated), or -1 on error\&. A frame larger than \fRlen - 1\fP is refused with -1 and \fRerrno\fP set to EMSGSIZE rather than truncated — note the frame is read off the socket in full before the size is known, so a refused frame is consumed and cannot be retried\&. -1 with \fRerrno\fP EAGAIN means the frame is still arriving and nothing was consumed\&. .RE .PP .SS "\fBio_ssize_t\fP ws_write (\fBsocket_t\fP fd, void * data, \fBio_size_t\fP n, int flags)" .PP Framed write hook installed into the I/O table\&. .PP \fBParameters\fP .RS 4 \fIfd\fP Socket descriptor\&. .br \fIdata\fP Source buffer\&. .br \fIn\fP Byte count\&. .br \fIflags\fP Operation flags\&. .RE .PP \fBReturns\fP .RS 4 The frame size, header included, once the frame is wholly written or queued for a non-blocking socket, or -1 if the connection failed\&. A non-negative result does not mean the bytes have left the socket: when the peer is slow the tail sits in the descriptor's write queue and is flushed by the event loop\&. The header goes through the same queue as the payload, so frames cannot interleave or be lost to EAGAIN\&. .RE .PP .SH "Author" .PP Generated automatically by Doxygen for axil from the source code\&.