Establishing a connection
We talked about two types of Internet Protocol (IP) in Chapter 2, Understanding the Networking Concepts. These are Transmission Control Protocol (TCP) and User Datagram Protocol (UDP). TCP is connection-oriented, which means data can be sent just after the connection has been established. In contrast, UDP is connectionless Internet protocol, which means the protocol just sends the data directly to the destination device. In this chapter, we will only talk about TCP; therefore, we have to establish the connection first. Connection can only be established if the two parties, in this case, the client and server, accept the connection. Here, we will try to establish a connection synchronously and asynchronously.
A synchronous client
We start with establishing the synchronous connection to a remote host. It is acting as a client, which will open a connection to the Packt Publishing website (www.packtpub.com). We will use TCP protocol, as we discussed earlier in Chapter...