Question
Translate this client java class to Perl programming language. import java.io.BufferedReader; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.InputStreamReader; import java.net.InetAddress; import java.net.Socket; public class client {
Translate this client java class to Perl programming language.
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.Socket;
public class client {
public static void main(String[] args) {
Socket sock = null;
InetAddress addr = null;
DataOutputStream sockStrm = null;
DataInputStream sockStrmIn= null;
InputStreamReader instrm = null;
BufferedReader stdin = null;
System.out.println("Client starting.");
try {
addr = InetAddress.getByName("");
sock = new Socket(addr,13544); // create client socket
} catch (Exception e) {
System.out.println("Creation of client's Socket failed.");
System.exit(1);
}
try {
instrm = new InputStreamReader(System.in);
stdin = new BufferedReader(instrm);
sockStrmIn = new DataInputStream(sock.getInputStream());
sockStrm = new DataOutputStream(sock.getOutputStream());
} catch (Exception e) {
System.out.println("Socket output stream failed.");
System.exit(1);
}
String clientInput="";
do{
try {
clientInput = stdin.readLine();
sockStrm.writeUTF(clientInput);
System.out.println(sockStrmIn.readUTF());
} catch (Exception e) {
System.out.println("Terminal read or socket output failed.");
System.exit(1);
}
}while(!clientInput.equals("E"));
try {
instrm.close();
stdin.close();
sockStrm.close();
sockStrmIn.close();
sock.close();
} catch (Exception e) {
System.out.println("Client couldn't close socket.");
System.exit(1);
}
System.out.println("Client finished.");
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started