Client Socket

Job ID: 35463305

Budget: $30 – $250 USD

Create a program that accepts a list of hostnames on the command line. For example

./a.out uwm.edu yahoo.com slashdot.net

For each hostname, the program attempts to connect to the associated ip address address on port 80, and sends

 "GET / HTTP/1.1\r\nHost: <address from argv> \r\nConnection: close\r\n\r\n"

through the socket. It then displays the hostname, ip address, and return code (302, 404, etc.) from the response for each host name in a table. Use printf() to format the table into columns. The IP addresses should be nicely formatted like 123.45.67.89 for an IPv4 address. IPv6 addresses can simply be displayed as hexadecimal.

Nonfunctional requirements

You must use the function inet_ntoa() to convert ipv4 addresses to formatted strings.

https://linux.die.net/man/3/inet_ntoa 

Sample run:

> ./a.out uwm.edu yahoo.com aol.com

Host                                IP Address                                Code

uwm.edu                        52.200.83.238                                302

yahoo.com                        74.6.231.21                                302

aol.com                        98.136.103.23                                302  

THE ATTACHED ZIP FILE HAS CODE THAT WILL HELP COMPLETE THIS PROJECT, KNOWLEDGE OF REPLIT IS HELPFUL