![]() | ![]() | ![]() | start-connection-server | ![]() |
|
| function port
&key backlog interface name reuse-address
=> thread | [Function] |
Purpose
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 |
Returns
The new connection-server thread.
Errors
Threads (multiprocessing) is not supported on the
Common Lisp implementation.
Description
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 "127.0.0.1".
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
kill-thread
open-connection
with-open-connection
Example
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)))
5555)
#<thread Connection Server>
Note
Use kill-thread to kill the connection-server thread.
The GBBopen Project
![]() | ![]() | ![]() | start-connection-server | ![]() |