• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Raw Sockets

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1246
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by "raw" socket???
 
Bhavin Shah
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1246
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic