java - 当 OP_ACCEPT 事件发生时,解复用器是如何被通知的

标签 java linux select nio

demultiplexer 可以用这个方法监控很多 socket fds 事件:

int select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);

从参数上看,有读事件、写事件和异常事件,但是accept事件在哪里呢?

最佳答案

这是 ServerSocket 上的读取事件。 select(2) 的手册页:

In order to be notified of incoming connections on a socket, you can use select(2) or poll(2). A readable event will be delivered when a new connection is attempted and you may then call accept() to get a socket for that connection.

关于java - 当 OP_ACCEPT 事件发生时,解复用器是如何被通知的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38407441/

相关文章:

linux - 在 Azure 上启动时在 Linux 实例上运行 init 脚本

python - 如何在python中同时监听命名管道和套接字

mysql - 从 select 语句 mysql 调用用户定义的存储过程

php - MAX_JOIN_SIZE 行; SET SQL_BIG_SELECTS=1 - 脚本在 2 年后停止工作

java - 使用 JFoenix 的 JFXDialog

java - 计算字符串中包含某个字符的单词数时得到错误的值

java - java中静态方法的用途

c++ - `libusb_attach_kernel_driver` 不工作

Java:如何以原子方式替换 Map 中的所有值?

php - CodeIgniter PHP - 如何在使用 "select *"时选择要在连接中选择的 ID