- Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathudpClient.java
More file actions
Latest commit
29 lines (22 loc) · 689 Bytes
/
Copy pathudpClient.java
File metadata and controls
29 lines (22 loc) · 689 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
/*
Write a program on datagram sockets for client/server to display message on client side,typed on server side.
*/
importjava.io.*;
importjava.net.*;
classudpClient
{
publicstaticvoidmain(String[] args) throwsIOException
{
//Set the port number on which the client must communicate to the server.
DatagramSocketds=newDatagramSocket(2345);
Stringmsg;
byte[] buf=newbyte[100];
while(true)
{
DatagramPacketrdp=newDatagramPacket(buf,buf.length);
ds.receive(rdp);
msg=newString(rdp.getData(),rdp.getOffset(),rdp.getLength());
System.out.println(msg);
}
}
}