Practice socket programming with threads: Write an 'echo' server using UDP. (This server does not need to be multi-threaded, but make sure that you do know how to implement a multi-threaded server when asked.) Each request is handled by replying to the client with the unmodified string the client sent.
Also, write an 'echo' client to test your server. Each client will send 20 sequentially numbered messages to the server & receive the replies. This code needs to be in java.
import java.io.*;
import java.net.*;
public class udpserver {
public static void main(String args[]) throws Exception
{
String rev;
System.out.println("Waiting for client");
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
byte[] sendData = new byte[1024];
byte[] receiveData = new byte[1024];
DatagramSocket server = new DatagramSocket(2100);
DatagramPacket receivePacket = new DatagramPacket(receiveData,
receiveData.length);
server.receive(receivePacket);
ans =new String( receivePacket.getData());
sendData=ans.getBytes();
InetAddress ip = receivePacket.getAddress();
int port = receivePacket.getPort();
DatagramPacket sendPacket = new
DatagramPacket(sendData,sendData.length,ip, port);
server.send(sendPacket);
}
import java.net.*;
import java.io.*;
public class udpclient {
public static void main(String args[]) throws Exception
{
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
DatagramSocket client = new DatagramSocket();
byte[] sendData = new byte [1024];
byte[] receiveData = new byte[1024];
InetAddress ip = InetAddress.getLocalHost();
System.out.println("Enter String");
String r = br.readLine();
sendData = r.getBytes();
DatagramPacket clientPacket = new DatagramPacket(sendData,
sendData.length, ip,2100);
client.send(clientPacket);
DatagramPacket receivePacket = new DatagramPacket(receiveData,
receiveData.length);
client.receive(receivePacket);
String ans = new String(receivePacket.getData());
receiveData=ans.getBytes();
System.out.println("FROM SERVER:" +ans);
client.close();
}
Practice socket programming with threads: Write an 'echo' server using UDP. (This server does not need...
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...
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. Implement a simple TCP Client-Server application 2. and analyze round trip time measurements for each of the above applications 3. The...
Using java socket programming rewrite the following program to handle multiple clients simultaneously (multi threaded programming) import java.io.*; import java.net.*; public class WelcomeClient { public static void main(String[] args) throws IOException { if (args.length != 2) { System.err.println( "Usage: java EchoClient <host name> <port number>"); System.exit(1); } String hostName = args[0]; int portNumber = Integer.parseInt(args[1]); try ( Socket kkSocket = new Socket(hostName, portNumber); PrintWriter out = new PrintWriter(kkSocket.getOutputStream(), true); BufferedReader in = new BufferedReader( new InputStreamReader(kkSocket.getInputStream())); ) { BufferedReader...
Here is the description of the client and server programs that you need to develop in C using TCP: Suppose we have a simple student query system, where the server keeps student's info in an array of struct student_info ( char abc123171 char name [101 double GPA; To simplify the tasks, the server should create a static array of 10 students with random abc123, name, and GPA in the server program. Then the server waits for clients. When a client...
I have to modify a server program and chat program to work as the following instructions but I am completely clueless as to where to start. I'd appreciate any help on how to atleast get started. This must be done in java. Diffie-Hellman Two parties use a key agreement protocol to generate identical secret keys for encryption without ever having to transmit the secret key. The protocol works by both parties agreeing on a set of values (a) and (q)....
C Programming - Please Help us! Implementing Load Balancing, the 3 Base Code files are at the bottom: Implementing Load Balancing Summary: In this homework, you will be implementing the main muti-threaded logic for doing batch based server load balancing using mutexes Background In this assignment you will write a batch-based load balancer. Consider a server which handles data proces- sing based on user requests. In general, a server has only a fixed set of hardware resources that it can...