Prev: Disk Database
bind() function instructs Coldmud to
listen on a port, with some object acting as a receiver object
for that port.
Network connections have associated with them a handler object.
When a connection occurs on a port, Coldmud initially uses the receiver
object for the port as the handler object for the connection, and sends
a connect message to the handler object, with two arguments: a
string giving the IP address of the remote host, and an integer giving
the port of the connection on the remote host. Because there is no way
to distinguish between connections with the same handler object, the
connect method on the handler object should arrange to have the
system object change either the receiver object for the port (using
bind()) or the handler object for the connection (using
conn_assign()).
When text arrives from a network connection, Coldmud sends a
parse message to the handler object for that connection, with the
text as a buffer argument. The parse method can then use
buffer_to_strings() to convert the buffer to a list of text
lines, if that is the usual form of input.
When a network connection is terminated, Coldmud sends a
disconnect message to the handler object for that connection.
Coldmud can also make make connections actively, using the
connect() function. The third argument to connect()
specifies a receiver object for the new connection; the server sends a
connect message to the receiver object upon success, or a
failed message to the receiver object upon failure, as described
in connect.