How it works...
So, we have defined a string of size 255 and a variable called client_Address of type sockaddr_in. We will invoke the socket function to create a socket by the name of clientSocket.
The address family that's supplied for the socket is AF_INET and is used for IPv4 internet protocols, and the socket type that's selected is stream socket type. The port number that's specified for the socket is 2000. By using the htons function, the short integer 2000 is converted into the network byte order before being applied as a port number.
We will set the fourth parameter, sin_zero, of the client_Address structure to NULL by invoking the memset function. We will initiate the connection to the clientSocket by invoking the connect function. ...
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