Question

In: Computer Science

This project will require you to demonstrate proficiency in programming using TCP/IP sockets by writing both...

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

Solutions

Expert Solution

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:

  1. import java.net.*;  
  2. import java.io.*;  
  3. class MyClient{  
  4. public static void main(String args[])throws Exception{  
  5. Socket s=new Socket("localhost",3333);  
  6. DataInputStream din=new DataInputStream(s.getInputStream());  
  7. DataOutputStream dout=new DataOutputStream(s.getOutputStream());  
  8. BufferedReader br=new BufferedReader(new InputStreamReader(System.in));  
  9.   
  10. String str="",str2="";  
  11. while(!str.equals("stop")){  
  12. str=br.readLine();  
  13. dout.writeUTF(str);  
  14. dout.flush();  
  15. str2=din.readUTF();  
  16. System.out.println("Server says: "+str2);  
  17. }  
  18.   
  19. dout.close();  
  20. s.close();  
  21. }}

Related Solutions

Write a program to implement a distributed chat server using TCP sockets in ‘C’.
Write a program to implement a distributed chat server using TCP sockets in ‘C’.
The objective of this homework assignment is to demonstrate proficiency with reading files, and using string...
The objective of this homework assignment is to demonstrate proficiency with reading files, and using string methods to slice strings, working with dictionaries and using-step wise development to complete your program. Python is an excellent tool for reading text files and parsing (i.e. filtering) the data. Your assignment is to write a Python program in four steps that reads a Linux authentication log file, identifies the user names used in failed password attempts and counts the times each user name...
This programming assignment is intended to demonstrate your knowledge of the following:  Writing a while...
This programming assignment is intended to demonstrate your knowledge of the following:  Writing a while loop  Write methods and calling methods Text Processing There are times when a program has to search for and replace certain characters in a string with other characters. This program will look for an individual character, called the key character, inside a target string. It will then perform various functions such as replacing the key character with a dollar-sign ($) wherever it occurs...
1.ARPANET originally used TCP/IP as a routing protocol for messages True False 2. Programming language developed...
1.ARPANET originally used TCP/IP as a routing protocol for messages True False 2. Programming language developed for business use and meant to run on multiple different computers. COBOL Fortran LISP BASIC 3.Transistors and vacuum tubes are no longer used in computers True False 4.The PDP series of minicomputers were developed by IBM. True False 5.Programming language popular with engineers because the code looked like algebra COBOL Fortran LISP BASIC
Implement the following socket programming in C (b) Chat Application using TCP
Implement the following socket programming in C (b) Chat Application using TCP
Explain both TCP/IP and ISO/OSI communication protocol stacks, identifying each of the protocol layers. How does...
Explain both TCP/IP and ISO/OSI communication protocol stacks, identifying each of the protocol layers. How does encapsulation work in this layered design? In terms of ratio header/payload, estimate the optimistic accumulate overhead these protocols incur for each application “packet” that is transmitted over the Internet.
In this homework, you will practice and reinforce the basics of socket programming for TCP connections...
In this homework, you will practice and reinforce the basics of socket programming for TCP connections in Python: how to create a socket, bind it to a specific address and port, as well as send and receive a HTTP packet. You will also learn some basics of HTTP header format. The requirements for this homework are specified below. 1. Function Requirement: You will develop a web server that handles one HTTP request at a time. Your web server should accept...
With given goal ,can you give me 3 interventions ? Goal: Demonstrate proficiency in pharmacology (...
With given goal ,can you give me 3 interventions ? Goal: Demonstrate proficiency in pharmacology ( with an emphasis on recognizing actions of drugs and administering drugs safely via various routes) on all assigned patients during clinical as nurse student, with minimal assistance.
For this project, you will create a program in C that will test the user’s proficiency...
For this project, you will create a program in C that will test the user’s proficiency at solving different types of math problems.   The program will be menu driven. The user will select either addition, subtraction, multiplication or division problems. The program will then display a problem, prompt the user for an answer and then check the answer displaying an appropriate message to the user whether their answer was correct or incorrect. The user will be allowed 3 tries at...
TCP client and server using C programming I am having trouble on how to read in...
TCP client and server using C programming I am having trouble on how to read in the IP adress and port number from the terminal Example: Enter IP address: 127.0.0.1 Enter Port Number: 8000 in both client and server code. How do can I make I can assign the Ip address and port number using the example above. the error I get is that the client couldn't connect with the server whenever i get the port number from the user...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT