Internet Programming Perl

Perl Programming


Perl language is ideal for writing Internet programming Perl applications. In a few lines of code, you will be able to create a network connection between a client and a server machine or even to develop a fully functional web server.

To manage network, web or internet connections, you should have some programming experience in Perl, including understanding the TCP/IP protocol on which relay the mail and browsing services, to mention only two of the most important ones.

Perl’s architecture, portability, the very large number of modules available that you can integrate into your application recommend this language for internet application.

Perl also provides full support for using sockets. If you want to connect two machines, you must write a program for each machine. The program that you want to receive a connection must create a socket, bind it to a port, and afterward it must wait for incoming connections. The other program – which initiates the call – will also create a socket, and it will supply the IP address and the listening port of the other machine. After the connection is established, the two programs can change information between them. At the end of the communication session, the connection is closed by the program which has initiated it.

When we speak about Internet Programming Perl, we have in view some services which you can develop: email, FTP, telnet, news, POP, SMTP, chat, web server, and so on.

The easiest way to manage the internet connections is using some appropriate modules available in great numbers at CPAN or from other sources. We’ll provide below some useful links which will help you choose the appropriate module for your network application.

Perl Telnet – for Internet Programming Perl applications

Perl Telnet represents an opportunity to use telnet protocol in Perl. Telnet is a network protocol you can use to make a connection with another computer on the Internet or local area network (LAN). A discussion about pros and cons of using this protocol in establishing a connection between two computers is beyond the scope of this page.

If you want to use Perl Telnet, perhaps you have your reasons (let’s say you want to telnet some servers to log on and verify the connection with each of them), so I will explain what options you have in using telnet from a Perl script below.

The straightforward way to do this is by using a module which can provide an interface necessary to connect through the telnet protocol. We recommend you to use the module Net::Telnet, available at CPAN. Made by Jay Rogers, this module is a free software and can be redistributed and modified under the same terms as Perl itself.

You can use the Net::Telnet module to create a telnet client able to make connections through a TCP port to a server. Be sure that on the other end of communication line the server you are connecting to have an authentic Telnet protocol; otherwise, some problems could appear. It’s the case of some remote ms-windows machines which come with a built-in telnet protocol that does not use the ASCII characters CR and LF to start a new line, which is essential for a “genuine” telnet protocol.

Besides traditional methods like print, get and getline, because the telnet protocol implies human interaction, some specific interactive features have been added: the ability to specify a timeout, to wait until some patterns appear in the input stream, etc.

Using this module, you have at least some opportunities:

  • Communicate with another host using a telnet port and implement some particular routines to help you log on
  • Getting a simple way to make connections to TCP services, without the hassle of using sockets
  • Ability to set your timeout for the connection, read and write operations

Leave a Reply

Your email address will not be published. Required fields are marked *