IntelliJ Java IDE
The moose likes Sockets and Internet Protocols and the fly likes Raw Sockets Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "Raw Sockets" Watch "Raw Sockets" New topic
Author

Raw Sockets

Bhavin Shah
Greenhorn

Joined: Dec 10, 2000
Posts: 7
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
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
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
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
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
What do you mean by "raw" socket???
Bhavin Shah
Greenhorn

Joined: Dec 10, 2000
Posts: 7
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
'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.
 
IntelliJ Java IDE
 
subject: Raw Sockets
 
Threads others viewed
Fetcth the Router's Mac Address
Layer 3 communication
How come I can ping a machine?
Bind java socket to a specific device
is telnet an application protocol or a connection protocol?
IntelliJ Java IDE