diff --git a/server1.c b/server1.c index da477c2..a5991a0 100644 --- a/server1.c +++ b/server1.c @@ -56,28 +56,22 @@ int main(int argc, char** argv) file_path = argv[optind + 1]; } - - int l; - 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 */ - - + // Open a TCP socket over IPv4 + sfd = socket(AF_INET, SOCK_SEQPACKET, 0); if (sfd == -1) { perror("socket fail"); - return EXIT_SUCCESS; + exit(EXIT_SUCCESS); } + int yes = 1; if (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) { perror("setsockopt error"); exit(5); } - l = sizeof(struct sockaddr_in); + int l = sizeof(struct sockaddr_in); bzero(&sock_serv, l); /* The following assignment should use; Internet version 4 protocols constant */