In: Computer Science
This project will require you to demonstrate proficiency in programming using TCP/IP sockets by writing both a client program and a server program to provide Roman numeral to Arabic number translation.
The client program must accept the –s servername flag and parameter to specify the hostname of the system running the server process, as well as accept the –p port-number flag and parameter indicating the port on which the server is listening. One (and only one) of the –r or –a flags will be provided by the user indicating Roman to Arabic or Arabic to Roman conversion, respectively. It is up to the client to check that a parameter to the –a flag is numeric and, conversely, a parameter to the –r flag is a string of only Roman numerals.
You will also write a program that runs as a server process and listens on a port specified by the user at execution time. It will read text input from its single network socket (indicated through the –p port-number flag and parameter), translate it and send back the results to the requester. The translation will be from Roman numeral to Arabic number or Arabic number to Roman numeral – the choice of which is indicated by the data sent by the client (numeric or character).
server socket:
import java.io.*;
import java.net.*;
public category MyServer association
DataInputStream dis=new DataInputStream(s.getInputStream());
String str=(String)dis.readUTF();
System.out.println("message= "+str);
ss.close();
}catch(Exception e)
}
}
client socket: