[英]Java Async I/O with NIO2: Does AsynchronousServerSocketChannel.accept give you an active AsynchronousSocketChannel
For server.accept I wrote a completion handler that has the parameters. 对于server.accept,我编写了具有参数的完成处理程序。
When the handler is invoked via the accept method, does that mean the AsynchronousSocketChannel is now conneted? 当通过accept方法调用处理程序时,这是否意味着AsynchronousSocketChannel现在已连接?
Or do I have to invoke the AsynchronousSocketChannel.connect method? 还是我必须调用AsynchronousSocketChannel.connect方法?
Right now what I think is going on is that AsynchronousServerSocketChannel.accept accepts a connection (and stores it in the AsynchronousSocketChannel parameter) , and that AsynchronousSocketChannel.connect also initiates a connection from server to client (stores in the socket channel). 现在,我认为正在发生的事情是AsynchronousServerSocketChannel.accept接受一个连接(并将其存储在AsynchronousSocketChannel参数中),并且AsynchronousSocketChannel.connect也启动了从服务器到客户端的连接(存储在套接字通道中)。
Am I on the right track? 我在正确的轨道上吗?
When the handler is invoked via the accept method, does that mean the AsynchronousSocketChannel is now conneted?
当通过accept方法调用处理程序时,这是否意味着AsynchronousSocketChannel现在已连接?
Yes. 是。
Or do I have to invoke the AsynchronousSocketChannel.connect method?
还是我必须调用AsynchronousSocketChannel.connect方法?
No. 没有。
Right now what I think is going on is that AsynchronousServerSocketChannel.accept accepts a connection (and stores it in the AsynchronousSocketChannel parameter)
现在,我认为正在发生的事情是AsynchronousServerSocketChannel.accept接受连接(并将其存储在AsynchronousSocketChannel参数中)
Yes. 是。
and that AsynchronousSocketChannel.connect also initiates a connection from server to client (stores in the socket channel).
并且AsynchronousSocketChannel.connect还会启动从服务器到客户端的连接(存储在套接字通道中)。
No. Obviously you haven't tried it. 不。显然您还没有尝试过。 It would fail.
它会失败。
accept()
is for servers. accept()
用于服务器。 connect()
is for clients. connect()
用于客户端。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.