Question
implement the follwing code using command promp or Eclipse or any other program you are familiar with. keep the name of the classes exatcly the same as requested for testing purpose. please follow each instruction provided below
Objective of this assignment o get you famililar with developing and implementing TCP or UDP sockets. What you need to do: I.
Part Il: UDP Capitalize Client-Server Repeat Part using UDP sockets. Call the client and server programs myFirstUDPClient,j
Objective of this assignment o get you famililar with developing and implementing TCP or UDP sockets. What you need to do: I. Implement a simple TCP Client-Server application 2. and analyze round trip time measurements for each of the above applications 3. The objective is to implement a client-server application using a safe method: start from a for the client and the server. You must slowly and carefully bend (modify) little by little the client and until you achieve your ultimate goal. You must bend and expand each piece alternatively ron. From time to time save your working client and server such that you can roll-back to the latest working Objective: server alternatively like the way a black-smith forges code in case of S. For this programming assignment, you are advised to start from the simple echo client and server to very simple application. Part h rcr Capithlize e bolient- Sclomr application Implement the following Client-Server application that will use two programs: a client program myFirst TCPClient.java and myFirstTCPServer-java a) Client: myFirstTCPClient.java This program must take two arguments: a hostname H and a port number P. The hostname h is a name or a decimal dotted-quad IP address of the server Sv. The port number P is any valid port number where the server Sv is binds to. This program must: I) Create a TCP client socket connected with the server Sv running on the machine with hostname (or IP address) h bound to Port number P 2) Repeatedly perform the following actions: i) Prompt the user to enter a sentence S ii) Send the sentence S to the server Sv ii) Receive the response from the server iv) Measure the duration between the time when the sentence S was sent and the time a response was received. and the time expressed in milliseconds. vi) Collect the round trip time. To implement the client myFirstTCPClientjava, you should consider start with the program TCPEchoClientjava (provided on Canvas with this programming assignment) Do not forget to change the name of the class inside the TCPEchoClient.java. b) Server: myFirstTCPServer.java This program must take one argument: a port number P. The port number P is any valid port number This program must: I) Create a TCP server socket 2) Wait for a client to connect, receive a message, display it with the IP address and port # of the client, capitalize the message, display the message, and echo back the "capitalized" message. To implement the server myfirstTCPServer java, you should consider start with the program TCPEchoServerjava (provided on Canvas with this programming assignment). Do not forget to change the name of the class inside the program TCPEchoServer.java
Part Il: UDP "Capitalize" Client-Server Repeat Part using UDP sockets. Call the client and server programs myFirstUDPClient,java and myFirstUDPServer java, respectively o implement the server (respectively, client) myFirstUDPServer java (respectively, myFirstUDPClient.java). you espectively, UDPEchoClien Timeoutjava) (provided on should consider start with the program UDPEchoServer.java( s Canvas with this s programming assignment). Do not forget to change the name of the class inside the program. Data collection and analysis For each application (UPD and TCP), report separately the min, average, and max round trip time.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

PROGRAM :

import java.io.*;
import java.net.*;
public class MyServer {
public static void main(String[] args){
try{
ServerSocket ss=new ServerSocket(6666);
Socket s=ss.accept();//establishes connection   
DataInputStream dis=new DataInputStream(s.getInputStream());
String str=(String)dis.readUTF();
System.out.println("message= "+str);
ss.close();
}
catch(Exception e){System.out.println(e);}
}
}

File: MyClient.java

import java.io.*;
import java.net.*;
public class MyClient {
public static void main(String[] args) {
try{
Socket s=new Socket("localhost",6666);
DataOutputStream dout=new DataOutputStream(s.getOutputStream());
dout.writeUTF("Hello Server");
dout.flush();
dout.close();
s.close();
}
catch(Exception e){System.out.println(e);}
}
}

>>Java Socket Programming
(customer will compose first to the server then server will get and print the content. At that point server will keep in touch with the customer and customer will get and print the content and progression goes on.)

File: MyServer.java

import java.net.*;
import java.io.*;
class MyServer{
public static void main(String args[])throws Exception{
ServerSocket ss=new ServerSocket(3333); //creating new socket with 3333
Socket s=ss.accept();
DataInputStream din=new DataInputStream(s.getInputStream());
DataOutputStream dout=new DataOutputStream(s.getOutputStream());
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str="",str2="";
while(!str.equals("stop")){
str=din.readUTF();
System.out.println("client says: "+str); //prints out to the desktop
str2=br.readLine();
dout.writeUTF(str2);
dout.flush();
}
din.close();
s.close();
ss.close();
}
}

File: MyClient.java

import java.net.*;
import java.io.*;
class MyClient{
public static void main(String args[])throws Exception{
Socket s=new Socket("localhost",3333); //creating new socket
DataInputStream din=new DataInputStream(s.getInputStream());
DataOutputStream dout=new DataOutputStream(s.getOutputStream());
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str="",str2="";
while(!str.equals("stop")){
str=br.readLine(); //reads single line at a time
dout.writeUTF(str);
dout.flush();
str2=din.readUTF();
System.out.println("Server says: "+str2);
}
dout.close();
s.close();
}
}

Add a comment
Know the answer?
Add Answer to:
implement the follwing code using command promp or Eclipse or any other program you are familiar with. keep the name of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using python 3 to create the UDP Ping Clien and server. Using UDP sockets, you will...

    Using python 3 to create the UDP Ping Clien and server. Using UDP sockets, you will write a client and server program that enables the client to determine the round-trip time (RTT) to the server. To determine the RTT delay, the client records the time on sending a ping request to the server, and then records the time on receiving a ping response from the server. The difference in the two times is the RTT. The ping message contains 2...

  • Write a program that shows the operation of TCP/IP socket. You are allowed to use any...

    Write a program that shows the operation of TCP/IP socket. You are allowed to use any programming language. You have to submit your code with a screenshot of the result after running the code. Useful links: https://www.javaworld.com/article/2077322/core-java-sockets-programming-in-java-atutorial.html https://www.c-sharpcorner.com/article/socket-programming-in-cpp-using-boost-asio-tcpserver-and-client/

  • please use java Advance Java CSCI 3210 Section Name: Date: Final Project (100 pts.) Instructions: Submit...

    please use java Advance Java CSCI 3210 Section Name: Date: Final Project (100 pts.) Instructions: Submit an electronic copy of the assignment to the Dropbox (Ex: ClassName.java, ClassNameTest.java, etc.) CHECK CALENDAR FOR DUE DATE IMPORTANT: FOLLOW GOOD PROGRAMMING STYLE/CONVENTION FOR NAMING ALL YOUR OBJECTS/VARIABLES. ADD COMMENTS ON TOP OF EACH METHOD AND AT TOP OF THE FILE, Final Project Requirements (TCP): The final project assignment is to create a Messaging Chat GUI, based on client/server framework. The default behavior is...

  • In this lab you will write a simple chat application in Python using TCP sockets. The...

    In this lab you will write a simple chat application in Python using TCP sockets. The chat application consists of a chat server and a chat client. At any one time, the chat server is communicating with just one chat client. When the client and the server are done chatting, they exchange end messages which ends the session. The client and server read and write Unicode strings using the readUTF() and writeUTF() methods of DataInputStream and DataOutputStream respectively. After compilation,...

  • In Python, make changes in the client code, so that the client allows the user to...

    In Python, make changes in the client code, so that the client allows the user to continue to send multiple requests until the user types in “Quit”. This means that the client process should not exit after the user sends one request and receives one response. Instead, the client process should be able to receive subsequent inputs from the user. You need to have a loop in the client code, so that it can accept the user request until the...

  • The following must be coded using Python programming language: In this assignment you will implement two...

    The following must be coded using Python programming language: In this assignment you will implement two programs: a chat client and a server. The server will listen to a known port for new connections from clients. When a client connects, it will be able to authenticate with the server and then join a chat room and send messages.

  • ND-OF-CHAPTER QUESTIONS Thought Questions 1. How do you think TCP would handle the problem if an ...

    ND-OF-CHAPTER QUESTIONS Thought Questions 1. How do you think TCP would handle the problem if an acknowledgment were lost, so that the sender retrans- mitted the unacknowledged TCP seg- ment, therefore causing the receiving transport process to receive the same segment twice? 2-2. a) Compute the minimum number of TCP segments required to open a con- nection, send an HTTP request and response message, and close the con- nection. Justify this number by creating a table showing each message and...

  • I need help with my IM (instant messaging) java program, I created the Server, Client, and...

    I need help with my IM (instant messaging) java program, I created the Server, Client, and Message class. I somehow can't get both the server and client to message to each other. I am at a roadblock. Here is the question below. Create an IM (instant messaging) java program so that client and server communicate via serialized objects (e.g. of type Message). Each Message object encapsulates the name of the sender and the response typed by the sender. You may...

  • Problem: Implement a FIFO program in which a client sends the server 3 variable names (strings)....

    Problem: Implement a FIFO program in which a client sends the server 3 variable names (strings). A valid variable name is defined for this assignment to be 6 characters or less, consisting only of lower-case letters from a to 'z', inclusive. The server checks the name for validity, and if valid, it counts the number of in the variable name. Each of the original variable names is sent back to the client, along with a message whether it is valid...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT