nerdexam
EC-Council

312-92 · Question #99

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 =…

The correct answer is D. Anyone. See the full explanation below for the reasoning.

Question

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) }

Options

  • AOnly those coming in on TCP port 10
  • BOnly those on the same subnet as the server
  • COnly those coming in on UDP port 10
  • DAnyone

How the community answered

(33 responses)
  • A
    15% (5)
  • B
    3% (1)
  • C
    6% (2)
  • D
    76% (25)

Community Discussion

No community discussion yet for this question.

Full 312-92 Practice