Fix IPv4 socket logic

This commit is contained in:
Thomas Wade 2018-11-01 11:06:16 +10:30
parent 28c9a69005
commit 626c54e66a

View File

@ -56,28 +56,22 @@ int main(int argc, char** argv)
file_path = argv[optind + 1]; file_path = argv[optind + 1];
} }
// Open a TCP socket over IPv4
int l; sfd = socket(AF_INET, SOCK_SEQPACKET, 0);
int yes = 1;
/* The following function call should use; Internet version 4 protocols with a sequenced, reliable, two-way connection based byte streams */
sfd = socket( /* Q) What goes here? */ , /* Q) What goes here? */ , 0);
/* See; man socket */
if (sfd == -1) if (sfd == -1)
{ {
perror("socket fail"); perror("socket fail");
return EXIT_SUCCESS; exit(EXIT_SUCCESS);
} }
int yes = 1;
if (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) if (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 )
{ {
perror("setsockopt error"); perror("setsockopt error");
exit(5); exit(5);
} }
l = sizeof(struct sockaddr_in); int l = sizeof(struct sockaddr_in);
bzero(&sock_serv, l); bzero(&sock_serv, l);
/* The following assignment should use; Internet version 4 protocols constant */ /* The following assignment should use; Internet version 4 protocols constant */