Which code fragment creates a server running at port 6666 and sends one line of text, "Hello from earth" over and over to any machine that connects to the server.
A) ServerSocket ss = new ServerSocket(6666) ;
Socket sock = ss.accept() ;
While (true)
{
PrintWriter pw = new PrintWriter(sock.getOutputStream() ) ;
Pw) println("Hello from earth") ;
Pw) flush() ;
Pw) close() ;
}
B) ServerSocket ss = new ServerSocket(6666) ;
While (true)
{
PrintWriter pw = new PrintWriter(sock.getOutputStream() ) ;
Pw) println("Hello from earth") ;
Socket sock = ss.accept() ;
}
C) ServerSocket ss = new ServerSocket(6666) ;
While (true)
{
Socket sock = ss.accept() ;
PrintWriter pw = new PrintWriter(sock.getOutputStream() ) ;
Pw) println("Hello from earth") ;
Pw) flush() ;
Pw) close() ;
}
D) Socket sock = ss.accept() ;
While (true)
{
ServerSocket ss = new ServerSocket(6666) ;
PrintWriter pw = new PrintWriter(sock.getOutputStream() ) ;
Pw) println("Hello from earth") ;
Pw) flush() ;
Pw) close() ;
}
Correct Answer:
Verified
Q21: Which of the following statements is correct?
A)HTML
Q25: What are the steps involved in designing
Q28: A(n) _ describes how data for a
Q30: Which of the following HTTP commands supplies
Q31: Show the command line that establishes a
Q32: Suppose that sock refers to a TCP
Q32: a(n. _ is a pointer to an
Q33: The _ is used to download received
Q35: Write a code fragment that connects to
Q36: Which of the following is not an
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents