Networking Fundamentals.
About Lesson

“Client” and “server” actually describe a pattern that’s much older and more widely used than the World Wide Web. These terms describe a really common way for computers to communicate, where one computer – the client – asks the questions, and the other – the server – provides the answers. It’s how the web works: a browser – aka a “web client” – loads a web page by requesting it from a “web server.” But there are other kinds of clients and servers as well. For example, if you’ve ever installed a Ruby gem you’ve used a client (RubyGems) to make a request to a gem server (possibly the one at rubygems.org) to get it.

Protocols

When a client sends a message to a server, it’s just a string of bytes. Just as humans need a common language in order to communicate, clients and servers need a common understanding of how to interpret the bytes they are sending back and forth. The shared rules that allow them to interpret messages is called a protocol.

The Internet

So, the internet is just a big network of clients and servers sending requests and responses back and forth. All this communication relies on two key protocols to make it work: IP and TCP.

IP

The first of these is a protocol for addresses, aka finding the right destination for a message. It’s called IP, or Internet Protocol. You’ve probably heard of IP addresses.

A port is used to differentiate among different applications using the same network interface. It is an additional qualifier used by the system software to get data to the correct application. Physically, a port is a 16-bit integer. Some ports are reserved for particular applications; they are labeled as well-known ports.

In the client/server model, the server provides a resource by listening for clients on a particular port. Some applications, such as FTP, SMTP, and Telnet, are standardized protocols and listen on a well-known port. Such standardized applications use the same port number on all TCP/IP hosts. For your client/server applications, however, you need a way to assign port numbers to represent the services you intend to provide. An easy way to define services and their ports is to enter them into data set hlq.ETC.SERVICES. In C, the programmer uses the getservbyname() function to determine the port for a particular service. Should the port number for a particular service change, only the hlq.ETC.SERVICES data set needs to be modified.