|
||||
EIFFELNET MANUAL4 THE PREDEFINED LEVELMany client-server applications follow a standard scheme that relies on the facilities outlined so far. When your application conforms to this scheme, you can avoid most of the work by relying on the client and server classes of the predefined level. There is no need to consider sockets explicitly or to worry about synchronization. As in many other cases found in the ISE Eiffel 3 libraries, the object-oriented method makes it possible here to encapsulate the standard pattern found in most usual cases. 4.1 The predefined client and server classesThe classes of the predefined level, which only support stream communication (not datagrams), are CLIENT, SERVER, and their descendants UNIX_CLIENT, UNIX_SERVER, NETWORK_CLIENT and NETWORK_SERVER. All the architecture of a client-server application is already available through these classes. All you have to do is to specify the address you want to use, what you want to send, when you want to send it, and what you want to do when you receive data. The rest will be taken care of automatically. The UNIX_ classes are meant for systems running on the same machine, using UNIX_STREAM_SOCKET; the NETWORK_ classes support inter-machine communication, using NETWORK_SOCKET. 4.2 Using the client classesWhen you want to write an application, your client should inherit from UNIX_CLIENT for example, and in your creation procedure, you have to setup your address, and then call the inherited make routine, with your address as an argument. You are then provided with some send and receive routines. 4.3 Using the server classesFor the server, you inherit for example from UNIX_SERVER. In the same way as for the client, you set up your address in the creation procedure, and then call the make creation procedure inherited from UNIX_SERVER. After that your creation procedure should call execute, which is inherited from SERVER, and provides you with a loop calling receive, process_message, respond and clean_up. Then, you should redefine these routines to do what you want your server to do. Previous Chapter Table of Contents Next Chapter
|