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:
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.
Call connect() to connect to the peer Using connect(), the client constructs the desired destination address and connects the socket to it.
Perform I/O on the socket The client calls Perl's various input and output operations to communicate ...