Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a UDP based file transfer program between 2 given IP addresses.PLEASE JAVA CODE SENDER CODE import java.net.*; class Sender { static public void main(String[]

write a UDP based file transfer program between 2 given IP addresses.PLEASE JAVA CODE SENDER CODE import java.net.*; class Sender { static public void main(String[] args) { DatagramSocket Sock; byte[] buf = new byte[ ]{'H','e','l','l','o',' ','w','o','r','l','d'}; try { Sock= new DatagramSocket(6666); InetAddress inetAddress=InetAddress.getByName("127.0.0.1"); DatagramPacket packet= new DatagramPacket(buf,buf.length,inetAddress, 6667); Sock.send(packet); System.out.println("Sent:"+ new String(buf)); Sock.close(); } catch(Exception e) { } } }

RECEIVER CODE

import java.net.*; class Receiver { static public void main(String[] args) { DatagramSocket Sock; byte[] buf = new byte[256]; try { Sock= new DatagramSocket(6667); DatagramPacket packet = new DatagramPacket(buf, buf.length); Sock.receive(packet); System.out.println("Received:" + new String(packet.getData()).trim()+ " From port:"+ packet.getPort()+ " LocalPort:"+Sock.getLocalPort()); Sock.close(); } catch(Exception e) { } } }

image text in transcribed

65432eadbce:6a:5x1:5d:4x(1)e::6

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Science Project Ideas In Health Care Volume 1

Authors: Zemelak Goraga

1st Edition

B0CPX2RWPF, 979-8223791072

More Books

Students also viewed these Databases questions

Question

What is Centrifugation?

Answered: 1 week ago

Question

To find integral of ?a 2 - x 2

Answered: 1 week ago

Question

To find integral of e 3x sin4x

Answered: 1 week ago

Question

To find the integral of 3x/(x - 1)(x - 2)(x - 3)

Answered: 1 week ago

Question

What are Fatty acids?

Answered: 1 week ago

Question

Is it clear what happens if an employee violates the policy?

Answered: 1 week ago