SocketChannel 文档中文翻译
2013-04-23 11:16
411 查看
A
the related
SocketChannel 是一个可选择的通道,提供部分抽象流连接的套接字。socket() 返回的相关的套接字实例,可处理套接字。
A socket channel is open but not connected when created by open(). After connecting it by calling connect(SocketAddress), it will remain connected until it gets closed. If the connection is non-blocking then connect(SocketAddress)
is used to initiate the connection, followed by a call of finishConnect() to perform the final steps of connecting. isConnectionPending() indicates if the connection is blocked or not; isConnected() indicates if the socket is finally connected or not.
一个套接字通道通过open()方法打开通道,但是此时没有连接。通过调用 connect(SocketAddress)来打开连接,它将保持连接,直到它获取关闭。如果连接处于非阻塞 connect(SocketAddress) 用于启动该连接,然后通过 finishConnect() 的调用来执行连接的最后步骤。isConnectionPending() 指示是否连接被阻止
;isConnected() 指示是否套接字最后连接。
The input and output sides of a channel can be shut down independently and asynchronously without closing the channel. The
of a channel and subsequent read operations return -1, which means end of stream. If another thread is blocked in a read operation when the shutdown occurs, the read will end without effect and return end of stream. The
is used for the output side of the channel; subsequent write operations throw a
If the output is shut down and another thread is blocked in a write operation, an
be thrown to the pending thread.
通道(channel)的输入和输出双方都可以独立并且异步的关闭,而不用关闭通道(channel).
shutdownInput 方法用于从通道里读取数据,当流到达末尾的时候返回-1.如果另一个线程在读取时被关闭阻塞,那么这个读取操作将在不被影响的情况下结束这个流,
shutdownOutput 方法用于向通道中写入数据,随后的写入操会抛出一个异常:ClosedChannelException,如果这个输出被关闭并且另一个线程在写入操作的时候被阻塞,将会抛出ClosedChannelException.
Socket channels are thread-safe, no more than one thread can read or write at any given time. The
are synchronized against each other; when they are processing, calls to
Socket channels
是线程安全的,在给定的时间里,不会有超过1个线程进行读取或者写入操作,(SocketAddress) and
SocketChannelis a selectable channel that provides a partial abstraction of stream connecting socket.
socket()returns
the related
Socketinstance which can handle the socket.
SocketChannel 是一个可选择的通道,提供部分抽象流连接的套接字。socket() 返回的相关的套接字实例,可处理套接字。
A socket channel is open but not connected when created by open(). After connecting it by calling connect(SocketAddress), it will remain connected until it gets closed. If the connection is non-blocking then connect(SocketAddress)
is used to initiate the connection, followed by a call of finishConnect() to perform the final steps of connecting. isConnectionPending() indicates if the connection is blocked or not; isConnected() indicates if the socket is finally connected or not.
一个套接字通道通过open()方法打开通道,但是此时没有连接。通过调用 connect(SocketAddress)来打开连接,它将保持连接,直到它获取关闭。如果连接处于非阻塞 connect(SocketAddress) 用于启动该连接,然后通过 finishConnect() 的调用来执行连接的最后步骤。isConnectionPending() 指示是否连接被阻止
;isConnected() 指示是否套接字最后连接。
The input and output sides of a channel can be shut down independently and asynchronously without closing the channel. The
shutdownInputmethod is used for the input side
of a channel and subsequent read operations return -1, which means end of stream. If another thread is blocked in a read operation when the shutdown occurs, the read will end without effect and return end of stream. The
shutdownOutputmethod
is used for the output side of the channel; subsequent write operations throw a
ClosedChannelException.
If the output is shut down and another thread is blocked in a write operation, an
AsynchronousCloseExceptionwill
be thrown to the pending thread.
通道(channel)的输入和输出双方都可以独立并且异步的关闭,而不用关闭通道(channel).
shutdownInput 方法用于从通道里读取数据,当流到达末尾的时候返回-1.如果另一个线程在读取时被关闭阻塞,那么这个读取操作将在不被影响的情况下结束这个流,
shutdownOutput 方法用于向通道中写入数据,随后的写入操会抛出一个异常:ClosedChannelException,如果这个输出被关闭并且另一个线程在写入操作的时候被阻塞,将会抛出ClosedChannelException.
Socket channels are thread-safe, no more than one thread can read or write at any given time. The
connect(SocketAddress)and
finishConnect()methods
are synchronized against each other; when they are processing, calls to
readand
writewill block.
Socket channels
是线程安全的,在给定的时间里,不会有超过1个线程进行读取或者写入操作,(SocketAddress) and
finishConnect()是互相同步的,当它们正在运行时,读取和写入操作会被阻止.
相关文章推荐
- socket官方文档中文翻译(部分)
- NetBeans中文社区文档/教程翻译项目
- ReactiveX文档中文翻译
- ujquery.fancybox api开发文档中文翻译版
- socket.io 中文手册 socket.io 中文文档
- php-fpm文档中文翻译
- 本人翻译的CMP Bean’s EJB QL中文文档:(由于本人英语有限,可能会有些误差L)
- NHibernate中文翻译文档
- Applying Styles and Themes - 应用Style和Theme - Android官方文档中文翻译
- socket.io 中文手册 中文文档
- SQLAlchemy 中文文档翻译计划
- 关于ContentProvider(Android SDK 中文翻译文档)
- ORCHARD中文文档(翻译)
- NetBeans中文社区文档/教程翻译项目
- jquery.ui.draggable中文文档(原文翻译)
- Redis 3.0中文官方文档翻译和源码解析
- Python UnitTest 文档中文翻译-5-6(渣翻自娱)
- java8 JDK1.8 API 中文 翻译版 java帮助文档