shutdown-socket-streamPortable Socketswith-open-connectionstart-connection-serverGoTo Top

start-connection-server   function port &key backlog interface name reuse-address => thread[Function]

Create a connection-server thread that accepts connections and processes them according to function.

Package   :portable-sockets

Module   :portable-sockets

Arguments and values

function     A function designator specifying a function object of one argument
port     An integer or a string specifying the service port
backlog     An integer (default is 5)
interface     A 32-bit internet address or a string specifying a network interface on the local machine or nil
name     A string (default is "Connection Server")
reuse-address     A generalized boolean (default is nil)
thread     A thread

The new connection-server thread.

Threads (multiprocessing) is not supported on the Common Lisp implementation.

The connection server will not accept another connection until function returns, so normally function should spawn another thread to handle the connection.

An interface string can be either a host name, such as "localhost" or a “dotted” IP address, such as "".

The value of backlog tells the operating system how many unprocessed connections can be held pending (connected but still awaiting an accept-connection).

See also

Start a simple connection server that accepts connections on port 5555, reads one line of input, and closes the connection:

  > (start-connection-server
       #'(lambda (connection)
            (let ((line (read-line connection nil)))
               (format t "~&;; New Connection: ~a~%" line)
               (close connection)))
  #<thread Connection Server>

Use kill-thread to kill the connection-server thread.

The GBBopen Project

shutdown-socket-streamPortable Socketswith-open-connectionstart-connection-serverGoTo Top