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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.