Question: Create a program that accepts a list of host names on the command line. For example ./a.out yahoo.com slashdot.net for each address, a child is
Create a program that accepts a list of host names on the command line. For example
./a.out yahoo.com slashdot.net
for each address, a child is spawned that attempts to connect to that address on port 80, and sends
"GET / HTTP/1.1 Host: Connection: close "
through the socket. If it receives data in response (reading the socket results in more than 0 bytes read) it end with return code 0, otherwise it returns -1.
The parent waits for all processes to end then prints the total number of children that returned 0.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
