Chapter 19: Network Programming


OVERVIEW

This chapter shows how Java and C++ can be used for network programming based in the client–server model. Today it is probably the most commonly used model for communicating between applications running on differentcomputers. It is also frequently used for establishing communication links between different applications running on the same computer.

In the client-server model, a server is usually a continuously running program that monitors a port for requests from other applications, called clients, wishing to communicate with the server through that port. The server and client roles apply only to individual communication links. That is, an application A can be a server with respect to application B's role as a client on one communication link. Yet, on a different communication link, application A could be a client to application B's role as a server.

Telnet service is a common example of the client-server model of communication. On the remote machine there is a constantly running program called telnetd (for telnet daemon) that monitors a designated port, port 23, for requests for telnet connections. When a client seeks such a connection, it runs a program called telnet that sends to the server machine a socket number, which is a combination of the IP address of the client machine together with the port number that the client will use for communicating with the server. When the server receives the client socket number, it acknowledges the request by sending back to the client its own socket number, meaning its IP address and the port on which it will communicate with the client.

In this chapter, we will first see how one can write client applications in Java to communicate with servers already in place. We will then show how one can set up both ends of a communication link. Next, we will show how C++ classes from the Qt library can be used for doing the same things.




Programming With Objects[c] A Comparative Presentation of Object-Oriented Programming With C++ and Java
Programming with Objects: A Comparative Presentation of Object Oriented Programming with C++ and Java
ISBN: 0471268526
EAN: 2147483647
Year: 2005
Pages: 273
Authors: Avinash Kak

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net