next up previous contents
Next: Sockets Up: Practical Perl Programming Previous: Summary

Networking with Perl

One of the reasons the Internet has blossomed so quickly is because everyone can understand the protocols that are spoken on the net. A protocol is a set of commands and responses. There are two layers of protocols that I'll mention here. The low-level layer is called TCP/IP and while it is crucial to the Internet, we can effectively ignore it. The high-level protocols like ftp, smtp, pop, http, and telnet are what you'll read about in this chapter. They use TCP/IP as a facilitator to communicate between computers. The protocols all have the same basic pattern:

Figure 18.1 illustrates the protocol for sending mail. The end-user creates a mail message and then the sending system uses the mail protocol to hold a conversation with the receiving system.

Network Protocol Communications Model

Internet conversations are done with sockets, in a manner similar to using the telephone or shouting out a window. I won't kid you, sockets are a complicated subject. They are discussed in the "Sockets" section that follows. Fortunately, you only have to learn about a small subset of the socket functionality in order to use the high-level protocols.

A list of the high-level protocols that you can use is given below with the protocol number in brackets. (We will not be able to cover them all here, but if you'd like to investigate further, the protocols are detailed in documents at the intdoc.html Web site.)

(113) -- Authentication
(7) -- Checks server to see if they are running

(79) -- Lets you retrieve information about a user

(21) -- File Transfer Protocol

(119) -- Network News Transfer Protocol: Usenet News Groups

(109) -- Post Office Protocol - incoming mail

(25) -- Simple Mail Transfer Protocol: outgoing mail

(37) -- Time Server

(23) -- Lets you connect to a host and use it as if you were a directly connected terminal

Each protocol is also called a service. Hence the term, mail server or ftp server. Underlying all of the high-level protocols is the very popular Transfer Control Protocol/Internet Protocol or TCP/IP. You don't need to know about TCP/IP in order to use the high-level protocols. All you need to know is that TCP/IP enables a server to listen and respond to an incoming conversation. Incoming conversations arrive at something called a port. A Port is an imaginary place where incoming packets of information can arrive (just like a ship arrives at a sea port). Each type of service (for example, mail or file transfer) has its own port number.

If you have access to a UNIX machine, look at the /etc/services file for a list of the services and their assigned port numbers. Users of Windows 95-and, I suspect Windows NT-can look in \windows\services.

In this chapter, we take a quick look at sockets, and then turn our attention to examples that use them. You see how to send and receive mail. Sending mail is done using the Simple Mail Transfer Protocol (SMTP). Receiving mail is done using the Post Office Protocol (POP).

next up previous contents
Next: Sockets Up: Practical Perl Programming Previous: Summary