In the following socket programming code, who will the server allow connections from?

In the following socket programming code, who will the server allow connections from?
int main(void)
{
int s1, s2;

s1 = socket(AF_INET, SOCK_STREAM, 0);
sin.sin_port = htons(30);
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = 0;
bind(sockfd, (struct sockaddr *)&sin, sizeof(sin));
listen(sockfd, 10);
s2 = accept(sockfd, 10);
write(s2, “hello\n”, 6)
}

In the following socket programming code, who will the server allow connections from?
int main(void)
{
int s1, s2;

s1 = socket(AF_INET, SOCK_STREAM, 0);
sin.sin_port = htons(30);
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = 0;
bind(sockfd, (struct sockaddr *)&sin, sizeof(sin));
listen(sockfd, 10);
s2 = accept(sockfd, 10);
write(s2, “hello\n”, 6)
}

A.
Only those coming in on TCP port 10

B.
Only those on the same subnet as the server

C.
Only those coming in on UDP port 10

D.
Anyone

Explanation:



Leave a Reply 0

Your email address will not be published. Required fields are marked *