Pro tip..
Code:
printf("Socket creation failed\n");
If the socket failed.. You probably want to exit the program.
Code:
fputs("Socket creation failed\n", stderr);
exit(1);