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

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
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.
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...
Problem: Make linkedList.h and linkList.c in Programming C language Project description This project will require students...
Problem: Make linkedList.h and linkList.c in Programming C language Project description This project will require students to generate a linked list of playing card based on data read from a file and to write out the end result to a file. linkedList.h Create a header file name linkedList Include the following C header files: stdio.h stdlib.h string.h Create the following macros: TRUE 1 FACES 13 SUITS 4 Add the following function prototypes: addCard displayCards readDataFile writeDataFile Add a typedef struct...
With my goal ,Can you give me interventions as a nurse student. Goal: 1. Demonstrate proficiency...
With my goal ,Can you give me interventions as a nurse student. Goal: 1. Demonstrate proficiency with nursing skills ( with an emphasis on IV therapy and tube feedings and skin treatments) on all assigned patients during my shift with minimal assistance.   
Create a project plan on the game or application you are creating. Using java programming. The...
Create a project plan on the game or application you are creating. Using java programming. The project plan should include the following: A description of the game or application The IDE or game engine your plan to use to create the game or app and information on how you are going to develop the game or app If you choose to create a game, how are you going to approach the game design and game development process or if you...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT