Home arrow Perl Programming arrow Page 2 - Socket Programming in PERL

Types of Sockets&toc - Perl

In this article, Rahul shows us how to create a client-server socket program in Perl and then demonstrates it by pinging the server.

TABLE OF CONTENTS:
  1. Socket Programming in PERL
  2. Types of Sockets
  3. Client–Server Script in PERL
  4. PERL Makes Life Easy
  5. Conclusion
By: Rahul Chauhan
Rating: starstarstarstarstar / 106
February 18, 2003

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
There are just two types of sockets: connection oriented and connection-less. There are other types but this classification is fair enough to get started, a socket has a domain (UNIX or internet), a connection type (connection oriented or connection less) and a protocol (TCP or UDP).

A connection oriented or a stream socket is a reliable two way communication. If you send three packets, say 1, 2 and 3, they are received in the same order they were sent. They achieve this high level of transmission quality by using TCP for error free reliable communication. The ubiquitous telnet application uses stream sockets.

The connection-less sockets or stream-less sockets use IP for routing but use the UDP. They are connectionless, since the connection need not be open as in stream sockets, the packet formed is given a destination IP address and than transmitted. This method is mostly used for packet-to-packet transfer as in ftp applications.

How a Packet is Formed

We will use an example of UDP packet for some light stuff on networking theory. It's Data Encapsulation. A packet is formed by encapsulating the data in a header at each level as it passes through the layers (protocol stack). At the receiving end the headers are stripped off as the packet travels up the layers to get the data.

Basically, at each layer, the protocol adds a header to the payload to perform the required functionality.

Client Server Architecture

It's a client-server world, today. Just about everything on the network deals with client processes talking to server processes and vice versa. Take the ubiquitous telnet, for instance. When you connect to a remote host on port 23 with telnet (the client), a program on that host (called telnetd, the server) springs to life. It handles the incoming telnet connection, sets up a login prompt, etc. Note that the client-server pair can speak in streaming or stream-less, or anything else (as long as they are speaking the same thing).

Some good examples of client-server pairs are telnet/telnetd, ftp/ftpd.



 
 
>>> More Perl Programming Articles          >>> More By Rahul Chauhan
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PERL PROGRAMMING ARTICLES

- Perl Turns 25
- Lists and Arguments in Perl
- Variables and Arguments in Perl
- Understanding Scope and Packages in Perl
- Arguments and Return Values in Perl
- Invoking Perl Subroutines and Functions
- Subroutines and Functions in Perl
- Perl Basics: Writing and Debugging Programs
- Structure and Statements in Perl
- First Steps in Perl
- Completing Regular Expression Basics
- Modifiers, Boundaries, and Regular Expressio...
- Quantifiers and Other Regular Expression Bas...
- Parsing and Regular Expression Basics
- Hash Functions

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: