如何在JVM中实现套接字? [英] How are sockets implemented in JVM?

查看:60
本文介绍了如何在JVM中实现套接字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,如何在Java虚拟机中实现套接字.

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

  • 是否包含本机库?
  • 如果是C库?

在哪里可以找到有关此主题的信息? 有关网络的官方Java教程对此没有帮助.

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

一些有趣的链接会有所帮助.

Some interesting links would help.

更新: Sun是否提供任何官方信息?

Update: Are there any official information provided by Sun?

提前谢谢!

修改 我找到了证明,我将答案标记为正确的答案.多亏了奥斯卡,这对我来说是个完美的提示!!!谢谢!

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

推荐答案

Java 1.4.2网络指南,提供了一条有趣的信息:

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

实施细节...

...您不需要知道的,除非您 子类 SocketImpl/DatagramSocketImpl. 每个 * Socket对象具有底层的SocketImpl/DatagramSocketImpl 本地代码的接口. Impl 类实现两种方法 支持选项:

...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) 抛出SocketException;目的 getOption(int optID)抛出 SocketException;

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

看起来很像C .这些方法 充当本机方法的粘合剂,并且 在本地之前确保类型安全 方法被调用.

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

所以我认为这是经过验证的:Java使用本地库作为套接字.

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

这篇关于如何在JVM中实现套接字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆