The lichat-tcp-server Reference Manual

This is the lichat-tcp-server Reference Manual, version 1.0.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Feb 26 16:53:54 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 lichat-tcp-server

A simple TCP server implementation for lichat.

Maintainer

Yukari Hafner <>

Author

Yukari Hafner <>

Home Page

https://Shirakumo.github.io/lichat-tcp-server/

Source Control

(GIT https://github.com/Shirakumo/lichat-tcp-server.git)

Bug Tracker

https://github.com/Shirakumo/lichat-tcp-server/issues

License

zlib

Version

1.0.0

Dependencies
  • lichat-protocol (system).
  • lichat-serverlib (system).
  • usocket (system).
  • bordeaux-threads (system).
  • documentation-utils (system).
  • verbose (system).
Source

lichat-tcp-server.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 lichat-tcp-server/lichat-tcp-server.asd

Source

lichat-tcp-server.asd.

Parent Component

lichat-tcp-server (system).

ASDF Systems

lichat-tcp-server.


3.1.2 lichat-tcp-server/package.lisp

Source

lichat-tcp-server.asd.

Parent Component

lichat-tcp-server (system).

Packages

lichat-tcp-server.


3.1.3 lichat-tcp-server/server.lisp

Dependency

package.lisp (file).

Source

lichat-tcp-server.asd.

Parent Component

lichat-tcp-server (system).

Public Interface
Internals

3.1.4 lichat-tcp-server/documentation.lisp

Dependency

server.lisp (file).

Source

lichat-tcp-server.asd.

Parent Component

lichat-tcp-server (system).


4 Packages

Packages are listed by definition order.


4.1 lichat-tcp-server

Source

package.lisp.

Nickname

org.shirakumo.lichat.tcp-server

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Special variables

Special Variable: *default-port*

The standard port on which the server will run.

Should be 1111.

Package

lichat-tcp-server.

Source

server.lisp.


5.1.2 Ordinary functions

Function: ensure-hostname (host-ish)

Ensures that the host-ish is turned into a hostname string.

Package

lichat-tcp-server.

Source

server.lisp.


5.1.3 Generic functions

Generic Function: close-connection (server)

Stop accepting incoming connections and close all existing ones.

Can be used with either a SERVER or a CONNECTION.

See CONNECTIONS
See THREAD
See SERVER
See CONNECTION

Package

lichat-tcp-server.

Methods
Method: close-connection ((connection connection))
Source

server.lisp.

Method: close-connection ((server server))
Source

server.lisp.

Generic Reader: connection-limit (object)
Package

lichat-tcp-server.

Methods
Reader Method: connection-limit ((server server))

automatically generated reader method

Source

server.lisp.

Target Slot

connection-limit.

Generic Writer: (setf connection-limit) (object)
Package

lichat-tcp-server.

Methods
Writer Method: (setf connection-limit) ((server server))

automatically generated writer method

Source

server.lisp.

Target Slot

connection-limit.

Generic Reader: connections (object)

Accessor to the list of connections on the server.

See SERVER
See CONNECTION

Package

lichat-tcp-server.

Methods
Reader Method: connections ((server server))

automatically generated reader method

Source

server.lisp.

Target Slot

connections.

Generic Writer: (setf connections) (object)
Package

lichat-tcp-server.

Methods
Writer Method: (setf connections) ((server server))

automatically generated writer method

Source

server.lisp.

Target Slot

connections.

Generic Function: establish-connection (socket server)

Responsible for establishing a new connection to a client.

This will construct and push a new CONNECTION object onto the server using the given socket. It will also launch the CONNECTION’s background handling thread.

Package

lichat-tcp-server.

Methods
Method: establish-connection (socket (server server))
Source

server.lisp.

Generic Function: handle-connection (server)

Handle the socket with the given object.

The object should be either a SERVER or a CONNECTION.

In the case of the server, it will listen for new clients and if one is found, call ESTABLISH-CONNECTION.

In the case of the client, it will first manage connection establishment as per the Lichat protocol, then repeatedly wait for a new update with a timeout. If the timeout is reached, a PING update is sent to the connection. If an update is received, it is PROCESSED. If the socket ever experiences a connection problem (timeout, shutdown, reset, etc) then the connection is immediately closed. Provides a CLOSE-CONNECTION restart as mandated by the serverlib.

See SERVER
See CONNECTION
See ESTABLISH-CONNECTION
See LICHAT-SERVERLIB:PROCESS

Package

lichat-tcp-server.

Methods
Method: handle-connection ((connection connection))
Source

server.lisp.

Method: handle-connection :around ((connection connection))
Source

server.lisp.

Method: handle-connection ((server server))
Source

server.lisp.

Generic Reader: hostname (object)

Accessor to the hostname of the connection.

See CONNECTION

Package

lichat-tcp-server.

Methods
Reader Method: hostname ((connection connection))

automatically generated reader method

Source

server.lisp.

Target Slot

hostname.

Reader Method: hostname ((server server))

automatically generated reader method

Source

server.lisp.

Target Slot

hostname.

Generic Writer: (setf hostname) (object)
Package

lichat-tcp-server.

Methods
Writer Method: (setf hostname) ((connection connection))

automatically generated writer method

Source

server.lisp.

Target Slot

hostname.

Writer Method: (setf hostname) ((server server))

automatically generated writer method

Source

server.lisp.

Target Slot

hostname.

Generic Reader: lock (object)

Accessor to the lock of the object that is used to mutually exclude access.

See SERVER
See CONNECTION
See USER
See CHANNEL

Package

lichat-tcp-server.

Methods
Reader Method: lock ((user user))

automatically generated reader method

Source

server.lisp.

Target Slot

lock.

Reader Method: lock ((channel channel))

automatically generated reader method

Source

server.lisp.

Target Slot

lock.

Reader Method: lock ((connection connection))

automatically generated reader method

Source

server.lisp.

Target Slot

lock.

Reader Method: lock ((server server))

automatically generated reader method

Source

server.lisp.

Target Slot

lock.

Generic Writer: (setf lock) (object)
Package

lichat-tcp-server.

Methods
Writer Method: (setf lock) ((user user))

automatically generated writer method

Source

server.lisp.

Target Slot

lock.

Writer Method: (setf lock) ((channel channel))

automatically generated writer method

Source

server.lisp.

Target Slot

lock.

Writer Method: (setf lock) ((connection connection))

automatically generated writer method

Source

server.lisp.

Target Slot

lock.

Writer Method: (setf lock) ((server server))

automatically generated writer method

Source

server.lisp.

Target Slot

lock.

Generic Function: open-connection (server)

Start accepting incoming connections on the server.

This will launch a background thread which will call HANDLE-CONNECTION on the socket and server.

See HANDLE-CONNECTION
See THREAD
See SERVER

Package

lichat-tcp-server.

Methods
Method: open-connection ((server server))
Source

server.lisp.

Generic Reader: ping-interval (object)

Accessor to the amount of seconds to wait for an update before sending a PING.

See SERVER

Package

lichat-tcp-server.

Methods
Reader Method: ping-interval ((server server))

automatically generated reader method

Source

server.lisp.

Target Slot

ping-interval.

Generic Writer: (setf ping-interval) (object)
Package

lichat-tcp-server.

Methods
Writer Method: (setf ping-interval) ((server server))

automatically generated writer method

Source

server.lisp.

Target Slot

ping-interval.

Generic Reader: port (object)

Accessor to the port of the connection.

See CONNECTION

Package

lichat-tcp-server.

Methods
Reader Method: port ((connection connection))

automatically generated reader method

Source

server.lisp.

Target Slot

port.

Reader Method: port ((server server))

automatically generated reader method

Source

server.lisp.

Target Slot

port.

Generic Writer: (setf port) (object)
Package

lichat-tcp-server.

Methods
Writer Method: (setf port) ((connection connection))

automatically generated writer method

Source

server.lisp.

Target Slot

port.

Writer Method: (setf port) ((server server))

automatically generated writer method

Source

server.lisp.

Target Slot

port.

Generic Reader: socket (object)

Accessor to the TCP socket of the connection.

See USOCKET:SOCKET
See CONNECTION

Package

lichat-tcp-server.

Methods
Reader Method: socket ((connection connection))

automatically generated reader method

Source

server.lisp.

Target Slot

socket.

Reader Method: socket ((server server))

automatically generated reader method

Source

server.lisp.

Target Slot

socket.

Generic Writer: (setf socket) (object)
Package

lichat-tcp-server.

Methods
Writer Method: (setf socket) ((connection connection))

automatically generated writer method

Source

server.lisp.

Target Slot

socket.

Writer Method: (setf socket) ((server server))

automatically generated writer method

Source

server.lisp.

Target Slot

socket.

Generic Reader: thread (object)

Accessor to the background processing thread of the object.

See SERVER
See CONNECTION

Package

lichat-tcp-server.

Methods
Reader Method: thread ((connection connection))

automatically generated reader method

Source

server.lisp.

Target Slot

thread.

Reader Method: thread ((server server))

automatically generated reader method

Source

server.lisp.

Target Slot

thread.

Generic Writer: (setf thread) (object)
Package

lichat-tcp-server.

Methods
Writer Method: (setf thread) ((connection connection))

automatically generated writer method

Source

server.lisp.

Target Slot

thread.

Writer Method: (setf thread) ((server server))

automatically generated writer method

Source

server.lisp.

Target Slot

thread.


5.1.4 Standalone methods

Method: init-connection :around ((connection connection) update)
Package

lichat-serverlib.

Source

server.lisp.

Method: make-channel ((server server) &rest initargs)
Package

lichat-serverlib.

Source

server.lisp.

Method: make-connection ((server server) &rest initargs)
Package

lichat-serverlib.

Source

server.lisp.

Method: make-user ((server server) &rest initargs)
Package

lichat-serverlib.

Source

server.lisp.

Method: process :around ((connection connection) (update create))
Package

lichat-serverlib.

Source

server.lisp.

Method: process :around ((connection connection) (update register))
Package

lichat-serverlib.

Source

server.lisp.

Method: send :around ((object object) (channel channel))
Package

lichat-serverlib.

Source

server.lisp.

Method: send ((object object) (connection connection))
Package

lichat-serverlib.

Source

server.lisp.

Method: teardown-connection :around ((connection connection))
Package

lichat-serverlib.

Source

server.lisp.

Method: teardown-connection :after ((connection connection))
Package

lichat-serverlib.

Source

server.lisp.


5.1.5 Classes

Class: channel

Channel class.

Access to the channel is properly handled for
mutual exclusion from threads by its LOCK. Particularly, the following methods are mutually excluded via this lock:

LICHAT-SERVERLIB:JOIN
LICHAT-SERVERLIB:LEAVE

See LICHAT-SERVERLIB:CHANNEL
See LOCK

Package

lichat-tcp-server.

Source

server.lisp.

Direct superclasses

backlogged-channel.

Direct methods
Direct slots
Slot: lock
Initform

(bordeaux-threads:make-recursive-lock)

Readers

lock.

Writers

(setf lock).

Class: connection

Connection class. Each connection to a client will have an instance of this class.

Access to the connection is properly handled for
mutual exclusion from threads by its LOCK. Particularly,
the following methods are mutually excluded via this lock:

LICHAT-SERVERLIB:SEND

See LICHAT-SERVERLIB:FLOOD-PROTECTED-CONNECTION
See SOCKET
See THREAD
See LOCK

Package

lichat-tcp-server.

Source

server.lisp.

Direct superclasses

flood-protected-connection.

Direct methods
Direct Default Initargs
InitargValue
:socket(error socket required.)
Direct slots
Slot: hostname
Initargs

:hostname

Readers

hostname.

Writers

(setf hostname).

Slot: port
Initargs

:port

Readers

port.

Writers

(setf port).

Slot: socket
Initargs

:socket

Readers

socket.

Writers

(setf socket).

Slot: thread
Initargs

:thread

Readers

thread.

Writers

(setf thread).

Slot: queue
Initform

(make-array 0 :adjustable t :fill-pointer t)

Readers

queue.

Writers

(setf queue).

Slot: back-queue
Initform

(make-array 0 :adjustable t :fill-pointer t)

Readers

back-queue.

Writers

(setf back-queue).

Slot: lock
Initform

(bordeaux-threads:make-recursive-lock)

Readers

lock.

Writers

(setf lock).

Class: server

Server class. You should instantiate this.

Access to the server is properly handled for
mutual exclusion from threads by its LOCK. Particularly, the following updates and processing methods for updates are mutually excluded via this lock:

LICHAT-SERVERLIB:TEARDOWN-CONNECTION LICHAT-PROTOCOL:CONNECT
LICHAT-PROTOCOL:REGISTER
LICHAT-PROTOCOL:CREATE

See LICHAT-SERVERLIB:FLOOD-PROTECTED-SERVER
See HOSTNAME
See PORT
See THREAD
See PING-INTERVAL
See LOCK
See CONNECTIONS

Package

lichat-tcp-server.

Source

server.lisp.

Direct superclasses

flood-protected-server.

Direct methods
Direct Default Initargs
InitargValue
:name(machine-instance)
:hostnamelocalhost
:port*default-port*
:threadnil
:ping-interval10
:connection-limit100
Direct slots
Slot: hostname
Initargs

:hostname

Readers

hostname.

Writers

(setf hostname).

Slot: port
Initargs

:port

Readers

port.

Writers

(setf port).

Slot: socket
Readers

socket.

Writers

(setf socket).

Slot: thread
Initargs

:thread

Readers

thread.

Writers

(setf thread).

Slot: ping-interval
Initargs

:ping-interval

Readers

ping-interval.

Writers

(setf ping-interval).

Slot: lock
Initform

(bordeaux-threads:make-recursive-lock)

Readers

lock.

Writers

(setf lock).

Slot: connections
Readers

connections.

Writers

(setf connections).

Slot: connection-limit
Initargs

:connection-limit

Readers

connection-limit.

Writers

(setf connection-limit).

Class: user

User class.

Access to the user is properly handled for
mutual exclusion from threads by its LOCK. Particularly, the following methods are mutually excluded via this lock:

LICHAT-SERVERLIB:JOIN
LICHAT-SERVERLIB:LEAVE

See LICHAT-SERVERLIB:USER
See LOCK

Package

lichat-tcp-server.

Source

server.lisp.

Direct superclasses

user.

Direct methods
Direct slots
Slot: lock
Initform

(bordeaux-threads:make-recursive-lock)

Readers

lock.

Writers

(setf lock).


5.2 Internals


5.2.1 Generic functions

Generic Reader: back-queue (object)
Package

lichat-tcp-server.

Methods
Reader Method: back-queue ((connection connection))

automatically generated reader method

Source

server.lisp.

Target Slot

back-queue.

Generic Writer: (setf back-queue) (object)
Package

lichat-tcp-server.

Methods
Writer Method: (setf back-queue) ((connection connection))

automatically generated writer method

Source

server.lisp.

Target Slot

back-queue.

Generic Reader: queue (object)
Package

lichat-tcp-server.

Methods
Reader Method: queue ((connection connection))

automatically generated reader method

Source

server.lisp.

Target Slot

queue.

Generic Writer: (setf queue) (object)
Package

lichat-tcp-server.

Methods
Writer Method: (setf queue) ((connection connection))

automatically generated writer method

Source

server.lisp.

Target Slot

queue.

Generic Function: send-queued-messages (connection)
Package

lichat-tcp-server.

Methods
Method: send-queued-messages ((connection connection))
Source

server.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   (  
B   C   E   F   G   H   I   L   M   O   P   Q   S   T  
Index Entry  Section

(
(setf back-queue): Private generic functions
(setf back-queue): Private generic functions
(setf connection-limit): Public generic functions
(setf connection-limit): Public generic functions
(setf connections): Public generic functions
(setf connections): Public generic functions
(setf hostname): Public generic functions
(setf hostname): Public generic functions
(setf hostname): Public generic functions
(setf lock): Public generic functions
(setf lock): Public generic functions
(setf lock): Public generic functions
(setf lock): Public generic functions
(setf lock): Public generic functions
(setf ping-interval): Public generic functions
(setf ping-interval): Public generic functions
(setf port): Public generic functions
(setf port): Public generic functions
(setf port): Public generic functions
(setf queue): Private generic functions
(setf queue): Private generic functions
(setf socket): Public generic functions
(setf socket): Public generic functions
(setf socket): Public generic functions
(setf thread): Public generic functions
(setf thread): Public generic functions
(setf thread): Public generic functions

B
back-queue: Private generic functions
back-queue: Private generic functions

C
close-connection: Public generic functions
close-connection: Public generic functions
close-connection: Public generic functions
connection-limit: Public generic functions
connection-limit: Public generic functions
connections: Public generic functions
connections: Public generic functions

E
ensure-hostname: Public ordinary functions
establish-connection: Public generic functions
establish-connection: Public generic functions

F
Function, ensure-hostname: Public ordinary functions

G
Generic Function, (setf back-queue): Private generic functions
Generic Function, (setf connection-limit): Public generic functions
Generic Function, (setf connections): Public generic functions
Generic Function, (setf hostname): Public generic functions
Generic Function, (setf lock): Public generic functions
Generic Function, (setf ping-interval): Public generic functions
Generic Function, (setf port): Public generic functions
Generic Function, (setf queue): Private generic functions
Generic Function, (setf socket): Public generic functions
Generic Function, (setf thread): Public generic functions
Generic Function, back-queue: Private generic functions
Generic Function, close-connection: Public generic functions
Generic Function, connection-limit: Public generic functions
Generic Function, connections: Public generic functions
Generic Function, establish-connection: Public generic functions
Generic Function, handle-connection: Public generic functions
Generic Function, hostname: Public generic functions
Generic Function, lock: Public generic functions
Generic Function, open-connection: Public generic functions
Generic Function, ping-interval: Public generic functions
Generic Function, port: Public generic functions
Generic Function, queue: Private generic functions
Generic Function, send-queued-messages: Private generic functions
Generic Function, socket: Public generic functions
Generic Function, thread: Public generic functions

H
handle-connection: Public generic functions
handle-connection: Public generic functions
handle-connection: Public generic functions
handle-connection: Public generic functions
hostname: Public generic functions
hostname: Public generic functions
hostname: Public generic functions

I
init-connection: Public standalone methods

L
lock: Public generic functions
lock: Public generic functions
lock: Public generic functions
lock: Public generic functions
lock: Public generic functions

M
make-channel: Public standalone methods
make-connection: Public standalone methods
make-user: Public standalone methods
Method, (setf back-queue): Private generic functions
Method, (setf connection-limit): Public generic functions
Method, (setf connections): Public generic functions
Method, (setf hostname): Public generic functions
Method, (setf hostname): Public generic functions
Method, (setf lock): Public generic functions
Method, (setf lock): Public generic functions
Method, (setf lock): Public generic functions
Method, (setf lock): Public generic functions
Method, (setf ping-interval): Public generic functions
Method, (setf port): Public generic functions
Method, (setf port): Public generic functions
Method, (setf queue): Private generic functions
Method, (setf socket): Public generic functions
Method, (setf socket): Public generic functions
Method, (setf thread): Public generic functions
Method, (setf thread): Public generic functions
Method, back-queue: Private generic functions
Method, close-connection: Public generic functions
Method, close-connection: Public generic functions
Method, connection-limit: Public generic functions
Method, connections: Public generic functions
Method, establish-connection: Public generic functions
Method, handle-connection: Public generic functions
Method, handle-connection: Public generic functions
Method, handle-connection: Public generic functions
Method, hostname: Public generic functions
Method, hostname: Public generic functions
Method, init-connection: Public standalone methods
Method, lock: Public generic functions
Method, lock: Public generic functions
Method, lock: Public generic functions
Method, lock: Public generic functions
Method, make-channel: Public standalone methods
Method, make-connection: Public standalone methods
Method, make-user: Public standalone methods
Method, open-connection: Public generic functions
Method, ping-interval: Public generic functions
Method, port: Public generic functions
Method, port: Public generic functions
Method, process: Public standalone methods
Method, process: Public standalone methods
Method, queue: Private generic functions
Method, send: Public standalone methods
Method, send: Public standalone methods
Method, send-queued-messages: Private generic functions
Method, socket: Public generic functions
Method, socket: Public generic functions
Method, teardown-connection: Public standalone methods
Method, teardown-connection: Public standalone methods
Method, thread: Public generic functions
Method, thread: Public generic functions

O
open-connection: Public generic functions
open-connection: Public generic functions

P
ping-interval: Public generic functions
ping-interval: Public generic functions
port: Public generic functions
port: Public generic functions
port: Public generic functions
process: Public standalone methods
process: Public standalone methods

Q
queue: Private generic functions
queue: Private generic functions

S
send: Public standalone methods
send: Public standalone methods
send-queued-messages: Private generic functions
send-queued-messages: Private generic functions
socket: Public generic functions
socket: Public generic functions
socket: Public generic functions

T
teardown-connection: Public standalone methods
teardown-connection: Public standalone methods
thread: Public generic functions
thread: Public generic functions
thread: Public generic functions