14.2 General Sockets
— Class: sb-bsd-sockets:socket
Class precedence list:
socket, standard-object, t
protocol — initarg:
Protocol used by the socket. If a
keyword, the symbol-name of the keyword will be passed to
get-protocol-by-name downcased, and the returned value used as
protocol. Other values are used as-is.
type — initarg:
Type of the socket:
Common base class of all sockets, not meant to be
— Generic Function: sb-bsd-sockets:socket-bind socket &rest address
address, which may vary according to
socket family. For the
inet family, pass
port as two
file address family sockets, pass the filename string.
See also bind(2)
— Generic Function: sb-bsd-sockets:socket-accept socket
Perform the accept(2) call, returning a
newly-created connected socket and the peer address as multiple
— Generic Function: sb-bsd-sockets:socket-connect socket &rest address
Perform the connect(2) call to connect
socket to a
peer. No useful return value.
— Generic Function: sb-bsd-sockets:socket-peername socket
Return the socket's peer; depending on the address
family this may return multiple values
— Generic Function: sb-bsd-sockets:socket-name socket
Return the address (as vector of bytes) and port
that the socket is bound to, as multiple values.
— Generic Function: sb-bsd-sockets:socket-receive socket buffer length &key oob peek waitall dontwait element-type element-type
length octets from
buffer (or a freshly-consed
buffer if NIL), using recvfrom(2). If
nil, the length of
buffer is used, so at least one of these two arguments must be
buffer is supplied, it had better be of an element type
one octet wide. Returns the buffer, its length, and the address of the
peer that sent it, as multiple values. On datagram sockets, sets
MSG_TRUNC so that the actual packet length is returned even if the
buffer was too small.
— Generic Function: sb-bsd-sockets:socket-send socket buffer length &key address external-format oob eor dontroute dontwait nosignal external-format
length octets from
socket, using sendto(2). If
is a string, it will converted to octets according to
nil, the length of the octet buffer is used. The format of
depends on the socket type (for example for
inet domain sockets it would
be a list of an
ip address and a port). If no socket address is provided,
send(2) will be called instead. Returns the number of octets written.
— Generic Function: sb-bsd-sockets:socket-listen socket backlog
socket as willing to accept incoming connections.
defines the maximum length that the queue of pending connections may
grow to before new connection attempts are refused. See also listen(2)
— Generic Function: sb-bsd-sockets:socket-open-p socket
Return true if
socket is open; otherwise, return false.
— Generic Function: sb-bsd-sockets:socket-close socket
socket. May throw any kind of error that
write(2) would have thrown. If
socket-make-stream has been called,
close on that stream instead
— Generic Function: sb-bsd-sockets:socket-make-stream socket &key input output element-type external-format buffering timeout element-type buffering external-format
Find or create a
stream that can be used for
socket (which must be connected). Specify whether the stream is for
output, or both (it is an error to specify neither).
external-format are as per
timeout specifies a read timeout
for the stream.
— Method: sb-bsd-sockets:socket-make-stream
) &key input output
)) (buffering full
) (external-format default
Default method for
socket objects. An
will construct a bivalent stream. Acceptable values for
:none. Streams will have no
The stream for
socket will be cached, and a second invocation of this
method will return the same stream. This may lead to oddities if this
function is invoked with inconsistent arguments (e.g., one might request
an input stream and get an output stream in response).
— Function: sb-bsd-sockets:socket-error where
— Generic Function: sb-bsd-sockets:non-blocking-mode socket
socket in non-blocking mode?