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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access