This cluster contains two very intersting classes since they provide a framework to build multiplexing servers.
SERVER
is a multiplexing server. IT can either start its
own stand-alone stack or use an existing stack. You give it an access and it listens onto it and starts
connections when a new client connects.CONNECTION
is a connection started by the server
whenever a client connects. A stream connected to that client is provided.This cluster provides the main collection abstractions and their implementations. This document provides a few hints that may help choosing the most relevant data structure.
Collections are linear sequences of objects. They are traversable by either using an index (an INTEGER between lower and upper) or an iterator.
The standard library implementations are:
COLLECTION2 and COLLECTION3 provide similar facilities for two- and three-dimension object collections.
Maps provide indexed collections: access to object values using object keys.
The standard library implementations are:
Sets of objects have unique occurrences of each object. Mathematical set operators are available.
The standard library implementations are:
A repository is a collection of STORABLE objects. The aim of this structure is to make objects persistent.
The standard library implementations are:
See also: REPOSITORY_TRANSIENT to register objects that must not be persisted.
How to use the "net" cluster
This page is divided into the following sections:
Vocabulary
Be a Client
To be client means trying to reach some server and getting some data from it.
There are two concepts to grasp before making a connection:
To be a client, you have to do three things, in that order:
In Liberty Eiffel, you would write it this way:
(See also the tutorial: class
SOCKETS
)Be a Server
To be a server, things are a bit more complex but not tremendously so.
First note that you must know something of the
lib/sequencer
cluster. You must also be familiar with agents.To create a server, start by creating an address and an access. The address will filter which connections are allowed1, and the access port will determine which port the server will listen to.
Now you must create a
SOCKET_SERVER
, give it one or more agents using the`when_connect'
feature. Those agents are called whenever a new client connects; each agent is given the same stream that represents the connection to the client.Note that having multiple agents is potentially dangerous. Either all the agents cooperate, either having one registered is enough. Remember that all agents share the same stream.