$Id: api-docs.shtml 417 2008-08-07 20:29:51Z ehuelsmann $
Work in progress.
Please note that we're committed to the interface described below for the entire 0.x phase of the library. When 1.0 comes some of the functionality may be split up in different functions and guarantees may change because of it.
Creates a tcp (stream) socket to the host and port specified. The return value is a socket object of class stream-usocket.
The element-type argument is used in the construction of the associated stream.
Creates and returns a passive ("server") socket associated with host and port. The object returned is of subtype stream-server-usocket.
host names a local interface.
port names a local port, or 0 (zero) to request a random free port.
reuse-address is a boolean (t, nil) value signalling reuse of the address is requested (or not).
backlog is the length of the queue containing connections which haven't actually been accepted yet.
element-type is the default element type used for sockets created by socket-accept. character is
the default when it's not explicitly provided.
Creates and returns an active ("connected") stream socket new-socket from the socket passed. The return value is a socket object of class stream-usocket.
element-type is the element type used to construct the associated stream. If it's not specified, the element-type of socket (as used when it was created by the call to socket-listen) is used.
Flushes the stream associated with the socket and closes the socket connection.
Returns the local address and/or port information of socket.
Returns the remote address and/or port information of socket. The socket passed to this function must be a connected socket.
Used to store sockets as used by the current implementation - may be any of socket handles, socket objects and stream objects
Used to store the stream associated with the tcp socket connection.
When you want to write to the socket stream, use this function.
Indicates the default element-type to be used when constructing streams off this socket when no element type is specified in the call to socket-accept.
The host to use with socket-listen to make the socket listen on all available interfaces.
The port number to use with socket-listen to make the socket listen on a random available port. The port number assigned can be retrieved from the returned socket by calling get-local-port.
(format (socket-stream socket) "Hello there~%") ;; output into buffers (force-output (socket-stream socket)) ;; <== flush the buffers, if any
(listen (usocket:socket-stream your-socket)) ==> NIL (if no input is available)
(usocket:wait-for-input (list socket1 socket2 socket3) :timeout <your optional timeout value>) ==> list-of-sockets-to-read-from
(trivial-sockets:open-socket-stream ....) with (usocket:socket-stream (usocket:socket-connect ...))And replace all invocations of
(trivial-sockets:socket-accept ...) with (usocket:socket-stream (usocket:socket-accept ...))And replace all invocations of
(trivial-sockets:open-server ...) with (usocket:socket-listen ...)