Write a code fragment that connects to a server running on gorge.divms.uiowa.edu at port 2345 and sends the message "Hello server" to the server and then reads the one-line response from the server.
A) Socket sock = new Socket(2345, gorge.divms.uiowa.edu) ;
PrintWriter pw = new PrintWriter(sock.getOutputStream() ) ;
Pw) println("Hello server") ;
Pw) flush() ;
String line = scan.nextLine() ;
Scanner scan = new Scanner(sock.getInputStream() ) ;
B) Socket sock = new Socket(gorge.divms.uiowa.edu) ;
PrintWriter pw = new PrintWriter(sock.getOutputStream() , 2345) ;
Pw) println("Hello server") ;
Pw) flush() ;
Scanner scan = new Scanner(sock.getInputStream() ) ;
String line = scan.nextLine() ;
C) Socket sock = new Socket(gorge.divms.uiowa.edu, 2345) ;
PrintWriter pw = new PrintWriter(sock.getOutputStream() ) ;
Pw) println("Hello server") ;
Pw) flush() ;
Scanner scan = new Scanner(sock.getInputStream() ) ;
String line = scan.nextLine() ;
D) Socket sock = new Socket(gorge.divms.uiowa.edu, 2345) ;
PrintWriter pw = new PrintWriter(sock.getInputStream() ) ;
Pw) println("Hello server") ;
Pw) flush() ;
Scanner scan = new Scanner(sock.getOutputStream() ) ;
String line = scan.nextLine() ;
Correct Answer:
Verified
Q24: What does the acronym SMTP stand for?
A)Simple
Q32: a(n. _ is a pointer to an
Q34: A _ is an object that encapsulates
Q35: Write a code fragment that connects to
Q44: To kill a server that was started
Q47: The _ method of the ServerSocket class
Q48: A print writer buffers the characters that
Q51: The _ method empties the buffer and
Q56: For test protocols, turn the socket streams
Q57: _ objects are used for communication (IO)
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