A TCP Echo Client

We'll start by developing a small TCP client that is more sophisticated than the examples we looked at in the previous chapter. By and large, clients are responsible for actively initiating their connection to a remote service. We have already seen the outlines of this process in Chapter 3. To review, a TCP client takes the following steps:

  1. Call socket() to create a socket Using the socket() function, the client creates a stream-type socket in the INET (Internet) domain using the TCP protocol.

  2. Call connect() to connect to the peer Using connect(), the client constructs the desired destination address and connects the socket to it.

  3. Perform I/O on the socket The client calls Perl's various input and output operations to communicate ...

Get Network Programming with Perl now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.