SocketAddress,Socket,SocketOptions,SockertImpl,2018-12-02 7:00-8:00 NIO源码阅读

阅读内容

 

abstract SocketAddress

 

This class represents a Socket Address with no protocol attachment.

As an abstract class, it is meant to be subclassed with a specific,

protocol dependent, implementation.

 

该类表示没有协议附件的套接字地址。

作为一个抽象类,它意味着要用一个特定的、

协议的依赖,实现。

 

It provides an immutable object used by sockets for binding, connecting, or

as returned values.

 

它提供了套接字用于绑定、连接或的不可变对象

作为返回值。

 

Class Socket

 

This class implements client sockets (also called just "sockets"). A socket is an endpoint for communication between two machines.

The actual work of the socket is performed by an instance of the {@code SocketImpl} class. An application, by changing the socket factory that creates the socket implementation,can configure itself to create sockets appropriate to the local firewall.

 

该类实现客户端套接字(也称为“套接字”)。套接字是两台机器之间通信的端点。

套接字的实际工作由{@code SocketImpl}类的一个实例执行。通过更改创建套接字实现的套接字工厂,应用程序可以配置自己来创建适合本地防火墙的套接字。

 

@author unascribed

@see java.net.Socket#setSocketImplFactory(java.net.SocketImplFactory)

@see java.net.SocketImpl

@see java.nio.channels.SocketChannel

@since JDK1.0

 

public static synchronized void setSocketImplFactory(SocketImplFactory fac) throws IOException

Sets the client socket implementation factory for the application. The factory can be specified only once.

When an application creates a new client socket, the socket implementation factory's {@code createSocketImpl} method is called to create the actual socket implementation.

为应用程序设置客户端套接字实现工厂。工厂只能指定一次。

当应用程序创建一个新的客户端套接字时,将调用套接字实现工厂的{@code createSocketImpl}方法来创建实际的套接字实现。

 

interface SocketOptions

 

Interface of methods to get/set socket options. This interface is implemented by: SocketImpl and DatagramSocketImpl Subclasses of these should override the methods of this interface in order to support their own options.

 

get/set 套接字 选项的方法的接口。这个接口是由:SocketImpl实现的,这些类的DatagramSocketImpl子类应该覆盖这个接口的方法,以便支持它们自己的选项。

 

The methods and constants which specify options in this interface are for implementation only. If you're not subclassing SocketImpl or DatagramSocketImpl, you won't use these directly. There are type-safe methods to get/set each of these options in Socket, ServerSocket,DatagramSocket and MulticastSocket.

 

在此接口中指定选项的方法和常量仅用于实现。如果没有子类化SocketImpl或DatagramSocketImpl,就不会直接使用它们。在Socket、ServerSocket、DatagramSocket和multiastsocket中,有一些类型安全的方法来get/set 这些选项。

 

abstract class SocketImpl

The abstract class {@code SocketImpl} is a common superclass of all classes that actually implement sockets. It is used to create both client and server sockets. A "plain" socket implements these methods exactly as described, without attempting to go through a firewall or proxy.

 

抽象类{@code SocketImpl}是所有实际实现套接字的类的公共超类。它用于创建客户机和服务器套接字。一个“普通”套接字完全按照描述实现这些方法,而不需要通过防火墙或代理。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值