Next: Socket Options, Previous: Sockets Overview, Up: Networking
Class precedence list:
socket, standard-object, tSlots:
protocol— initarg::protocol; reader:sb-bsd-sockets:socket-protocolProtocol used by the socket. If a keyword, the symbol-name of the keyword will be passed to
get-protocol-by-namedowncased, and the returned value used as protocol. Other values are used as-is.type— initarg::type; reader:sb-bsd-sockets:socket-typeType of the socket:
:streamor:datagram.Common base class of all sockets, not meant to be directly instantiated.
Bind
sockettoaddress, which may vary according to socket family. For theinetfamily, passaddressandportas two arguments; forfileaddress family sockets, pass the filename string. See also bind(2)
Perform the accept(2) call, returning a newly-created connected socket and the peer address as multiple values
Perform the connect(2) call to connect
socketto a remotepeer. No useful return value.
Return the socket's peer; depending on the address family this may return multiple values
Return the address (as vector of bytes) and port that the socket is bound to, as multiple values.
Read
lengthoctets fromsocketintobuffer(or a freshly-consed buffer if NIL), using recvfrom(2). Iflengthisnil, the length ofbufferis used, so at least one of these two arguments must be non-NIL. Ifbufferis 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.
Send
lengthoctets frombufferintosocket, using sendto(2). Ifbufferis a string, it will converted to octets according toexternal-format. Iflengthisnil, the length of the octet buffer is used. The format ofaddressdepends on the socket type (for example forinetdomain sockets it would be a list of anipaddress and a port). If no socket address is provided, send(2) will be called instead. Returns the number of octets written.
Mark
socketas willing to accept incoming connections.backlogdefines the maximum length that the queue of pending connections may grow to before new connection attempts are refused. See also listen(2)
Close
socket. May throw any kind of error that write(2) would have thrown. Ifsocket-make-streamhas been called, callscloseon that stream instead
Find or create a
streamthat can be used forioonsocket(which must be connected). Specify whether the stream is forinput,output, or both (it is an error to specify neither).element-typeandexternal-formatare as peropen.timeoutspecifies a read timeout for the stream.
Default method for
socketobjects. Anelement-typeof:defaultwill construct a bivalent stream. Acceptable values forbufferingare:full,:lineand:none. Streams will have notimeoutby default. The stream forsocketwill 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).