[Main page] [Overview]     /daemon /sockets

SYNOPSIS
#include <daemons>

SOCKETD->...

FILE
/daemon/sockets.c

DESCRIPTION

How does the socketd work internally?

Each connection has an associated socket object which handles all
communication with the wizards object. These objects stay in the
inventory of the socketd.

To destringuish the different connections when a messages comes
in from the erq the clone number of the socket object is used.
The number is closured with the callback function. The number
is used instead of the object itself because the object may be
destructed meanwhile: the connection is to be killed then but the
ticket is needed for that. So we need some unique identifier that
is still usable after the object's destruction.

All opened connections are stored in sockets with the unique identifier
(the clone number of the socket object) as key. Furthermore there is
used_fd which translates unique identifieres to file descriptor numbers
which are used outside the socketd to identify a connection. The fds
are numbered from 0 to n using old numbers if that fd is not active
anymore.

If write() or send() is issued on a connection that is not open yet
the data will be buffered and sent when the socket becomes writabe.
It is even possible to disconnect() the socket wich will be delayed until
all buffered data is sent. Bear in mind that a disconnect() will not destruct
the socket object in that case and you will get the callbacks if the
issuing object still exists. If it does not exist anymore you cannot
tell if the data is really sent or some timeout occured. So in general
you should wait with send()s until the connection is established.



SUBTOPICS
accept   disconnect   get_state   new  
read_line   send   write