• Post Reply Bookmark Topic Watch Topic
  • New Topic

Raw Sockets

 
Bhavin Shah
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jim Bertorelli
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1245
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does java have Raw Sockets support?? i know old version doesn't but not sure now.
 
Jim Bertorelli
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "raw" socket???
 
Bhavin Shah
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1245
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!