views:

398

answers:

3

Hi folks!

I want to know, how sockets are implemented in the Java Virtual Machine.

  • Is there a native library included?
  • And if, is it a C library?

Where can I find information about this topic? The offical Java tutorial on networking does not help me there.

Some interesting links would help.

Update: Are there any official information provided by Sun?

Thanks in advance!

Edit I found a proof, I mark my answer as the correct one. Thanks to Oscar, that was the perfect hint for me!!! THANKS!

+3  A: 

Probably using the system-V socket calls exposed by the underlying platform, e.g. system-V under Unix, WinSock under Windows. The specification only dictates how a virtual machine must behave, so implementers are free to do as they wish.

Rob
+4  A: 
OscarRyz
It's hard to mark this question as the answer, because I need an official citation o.s.e. +1 of course
furtelwart
A: 

In the network guide of Java 1.4.2, an interesting piece of information is provided:

The implementation details...

...that you don't need to know, unless you subclass SocketImpl/DatagramSocketImpl. Every *Socket object has an underlying SocketImpl/DatagramSocketImpl that interfaces to native code. The Impl classes implement two methods to support options:

void setOption(int optID, Object val) throws SocketException; Object getOption(int optID) throws SocketException;

that look much like C. These methods act as glue to the native methods, and ensure type safety before native methods are invoked.

So I think it's proofed: Java uses native libraries for sockets.

furtelwart
Well, from the source I can tell that method is "native" thus uses a native library that could be either in C, C++ or assembly. As for the quote, documentation is not running software. :) What is the rationale of your question anyway?
OscarRyz
I need to compare network programming techniques in Linux and Windows of Java and Python.
furtelwart