0% found this document useful (0 votes)
5 views3 pages

Program 7

The document contains Java code for a simple UDP server and client. The server listens for incoming messages, converts them to uppercase, and sends them back to the client. The client sends a string to the server and displays the modified response received from the server.

Uploaded by

kls778217
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Program 7

The document contains Java code for a simple UDP server and client. The server listens for incoming messages, converts them to uppercase, and sends them back to the client. The client sends a string to the server and displays the modified response received from the server.

Uploaded by

kls778217
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

code UDP SERVER

import [Link].*;
import [Link];
class UDPServer
{
public static void main(String args[])throws Exception
{
DatagramSocket serverSocket = new DatagramSocket(9876);
byte[] receiveData=new byte[1024];
byte[] sendData=new byte[1024];
while(true)
{
[Link]("Server is Up");

DatagramPacket receivePacket=new
DatagramPacket(receiveData,[Link]);

[Link](receivePacket);

String sentence=new String([Link]());

[Link]("RECEIVED:"+sentence);

InetAddress IPAddress=[Link]();

int port=[Link]();

String capitalizedSentence=[Link]();

sendData=[Link]();

DatagramPacket sendPacket=new
DatagramPacket(sendData,[Link],IPAddress,port);

[Link](sendPacket);
}
}
}
Code UDP SERVER

import [Link].*;
import [Link].*;
import [Link];
class UDPClient
{
public static void main(String[] args)throws Exception
{
BufferedReader inFromUser=new BufferedReader(new
InputStreamReader([Link]));

DatagramSocket clientSocket=new DatagramSocket();

InetAddress IPAddress=[Link]("localhost");

byte[] sendData=new byte[1024];


byte[] receiveData=new byte[1024];

[Link]("Enter the sting to be converted in to Upper case");


String sentence=[Link]();

sendData=[Link]();

DatagramPacket sendPacket=new
DatagramPacket(sendData,[Link],IPAddress,9876);

[Link](sendPacket);

DatagramPacket receivePacket=new
DatagramPacket(receiveData,[Link]);

[Link](receivePacket);

String modifiedSentence=new String([Link]());

[Link]("FROM SERVER:"+modifiedSentence);

[Link]();
}
}

You might also like