-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathudpreceiver.java
More file actions
29 lines (28 loc) · 859 Bytes
/
Copy pathudpreceiver.java
File metadata and controls
29 lines (28 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
import java.net.DatagramPacket;
import edu.utulsa.unet.UDPSocket; //import java.net.DatagramSocket;
import java.net.InetAddress;
public class udpreceiver {
static final int PORT = 32456;
public static void main(String[] args)
{
try
{
byte [] buffer = new byte[11];
UDPSocket socket = new UDPSocket(PORT);
DatagramPacket packet = new DatagramPacket(buffer,buffer.length);
socket.receive(packet);
InetAddress client = packet.getAddress();
System.out.println(" Received'"+new String(buffer)+"' from "
+packet.getAddress().getHostAddress()+" with sender port "+packet.getPort());
}
catch(Exception e){ e.printStackTrace(); }
}
}