File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes DatagramSocket.receive(...) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "DatagramSocket.receive(...)" Watch "DatagramSocket.receive(...)" New topic


S Thanigaivel
Ranch Hand

Joined: Oct 06, 2005
Posts: 60
I send data of size 750 bytes from client to server using UDP.

I use the below code to receive data

The data I receive is of size 2048 bytes. Original size of my data is 750 bytes. What will be padded to the remaining 1298 bytes?
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
From java api
Datagram packets are used to implement a connectionless packet delivery service. Each message is routed from one machine to another based solely on information contained within that packet. Multiple packets sent from one machine to another might be routed differently, and might arrive in any order. Packet delivery is not guaranteed.

Just send the amount of bytes that contains data.

I agree. Here's the link:
subject: DatagramSocket.receive(...)
It's not a secret anymore!