0% found this document useful (0 votes)
8 views1 page

Server Code

Uploaded by

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

Server Code

Uploaded by

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

Exp 17_2 }

f.close();
Server Code: dsoc.send(new
import java.io.*; DatagramPacket(b,i,InetAddress.getLocal
import java.net.*; Host(),2019));}
public class Exp17_Ex2_server }
{
public static void main(String args[])throws
IOException
{
byte b[]=new byte[3072];
DatagramSocket dsoc=new
DatagramSocket(2019); Before:
FileOutputStream f=new
FileOutputStream("sfile.txt");
DatagramPacket dp=new
DatagramPacket(b,b.length);
dsoc.receive(dp);
String data = new
String(dp.getData(),0,dp.getLength());
f.write(data.getBytes(), 0, data.length());
} After:
}

Client Code:
import java.io.*;
import java.net.*;
public class Exp17_Ex2_client
{
public static void main(String args[])throws
Exception{
byte b[] = new byte[1024];
FileInputStream f = new
FileInputStream("cfile.txt");
DatagramSocket dsoc = new
DatagramSocket();
int i=0;
while(f.available() != 0)
{
b[i]=(byte)f.read();
i++;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy