Unix & Linux provide access to the IP & the Data Link layer using raw sockets. Does Java provide any such access? Or does java have any API which will allow me to directly access the IP & the Data Link Layer? Thanks, Bhavin
Sean MacLean
author
Ranch Hand
Joined: Nov 07, 2000
Posts: 621
posted
0
What sort of access do you mean? You can certainly create raw sockets through Java using the java.net.Socket class. Socket socket = new Socket( InetAddress.getByName( "sun.com"), 80 ); Sean
Shubhrajit Chatterjee
Ranch Hand
Joined: Aug 23, 2001
Posts: 356
posted
0
I don't think java has apis to do coding at ip or datalink layer. It can go down upto the layer in which tcp udp etc. recides. ------------------ Shubhrajit
Shubhrajit
Jim Bertorelli
Ranch Hand
Joined: Nov 28, 2001
Posts: 136
posted
0
Originally posted by Bhavin Shah: Unix & Linux provide access to the IP & the Data Link layer using raw sockets. Does Java provide any such access? Or does java have any API which will allow me to directly access the IP & the Data Link Layer? Thanks, Bhavin
No, It does not. You may search for some JNI wrappers, though.
Fei Ng
Ranch Hand
Joined: Aug 26, 2000
Posts: 1238
posted
0
does java have Raw Sockets support?? i know old version doesn't but not sure now.
Jim Bertorelli
Ranch Hand
Joined: Nov 28, 2001
Posts: 136
posted
0
What do you mean by "raw" socket???
Bhavin Shah
Greenhorn
Joined: Dec 10, 2000
Posts: 7
posted
0
Raw sockets allow one to directly access the IP & Datalink layer , bypassing the transport layer. By that I mean one can directly construct IP headers and even Datalink headers for network packets. This is mostly used for writing 'sniffer' kind of applications or writing applications like 'ping' , traceroute', etc where the IP header is constructed by the application programmer rather than the Unix/Linux kernel. Raw sockets are also used for writing a lot of Network Management applications, ICMP error monitoring, etc. I guess my earlier question was not clear; in the sense that I assumed people will understand by what is meant by "Raw Sockets". Anyway, thanks a lot. Bhavin
Fei Ng
Ranch Hand
Joined: Aug 26, 2000
Posts: 1238
posted
0
'sniffer' , few months ago i wanted some like that too but i was told java couldn't do that. You probably need jni and outside help. But i didn't want it to depend on an OS so i gave up. I doubt it that java has raw sockets. I know and know java 1.1 doesn't.