Fix IPv4 socket logic
This commit is contained in:
parent
28c9a69005
commit
626c54e66a
16
server1.c
16
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 */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user