Can I do low level network programming in Java?

By : Jim
Source: Stackoverflow.com
Question!

An application level message is send over the network in a series of packets that are assembled in the receiving side and passed to the application level.
Is it possible in Java to do network programming in the level of these individual packets?
Or in Java we can only see the "application" level packet? I.e. the "big-packet" that is assembled by all these network packets?
I tried to research on google for this matter but the results where really confusing.
The confusion is due to the fact that some resources that are about UDP seem to indicate that the operation is on packets, while others say that Java can not work in raw sockets which implies that it works on a higher level of abstraction.I could not find an answer to exactly what I am looking for. If yes, which package does this?

By : Jim


Answers

You won't see packetized segments if some other device breaks your large UDP packet into smaller packets.

When reading TCP you'll read bytes as a stream. You'll have no idea how these bytes were actually sent. You could read back 100 bytes, and they could have been sent over 10 packets for all you know.

There's no way to access this information in java without JNI. Of course with JNI you can do anything :)



You seem to think that UDP == raw. It doesn't. Raw == IP, or even Ethernet. UDP is a layer over IP, as is TCP. You can't work in raw sockets in Java but you can work in UDP and TCP.

By : EJP


This video can help you solving your question :)
By: admin