简体   繁体   English

发送EPOLLIN事件到epoll_wait

[英]Send EPOLLIN event to epoll_wait

Is it possible to manually send EPOLLIN event to epoll for socket file descriptor without writing data to the socket? 是否可以将EPOLLIN事件手动发送到epoll以获取套接字文件描述符,而无需将数据写入套接字?

Maybe it is possible to use fcntl or ioctl to stop epoll_wait function, isn't it? 也许可以使用fcntlioctl来停止epoll_wait函数,不是吗?

UPDATE : 更新

I understand that in most cases it does not make sense to do this, but I think it does make sense in my case. 我知道在大多数情况下这样做是没有道理的,但是我认为在我的情况下确实有道理。

I'm writing a network plugin for a program, which I cannot modify. 我正在为程序编写网络插件,无法修改。 The plugin API gives me a socket FD and tells me to write a function to read n bytes from the socket. 插件API给了我一个套接字FD,并告诉我编写一个函数从套接字读取n个字节。 I use ssl_read function from the polarssl library for this, which reads all the data into its own inner buffer, that is more than n bytes. 为此,我使用了polarssl库中的ssl_read函数,该函数将所有数据读入其自己的内部缓冲区中,即n个字节以上。

What happens in the program? 程序中会发生什么? The program waits ( epoll_wait ) when the socket receives data and then tells the plugin to read about 4kB of data. 套接字接收数据时,程序将等待( epoll_wait ),然后告诉插件读取大约4kB的数据。 And then it waits for the next data to be received by the socket. 然后,它等待套接字接收下一个数据。 When the socket receives 12kB of data, the program calls the read function within the plugin, which reads all the data with ssl_read function. 当套接字接收到12kB数据时,程序将调用插件中的read函数,该插件将使用ssl_read函数读取所有数据。 As a result, there's no more data available for the socket, but the polarssl library has it's own buffer, which has about 8kB of data available. 结果,没有更多的数据可用于套接字,但是polarssl库具有其自己的缓冲区,该缓冲区具有大约8kB的可用数据。

So now I need to tell the program to call the read function of the plugin, which is not going to read data from the socket directly, but is going to read data from inner polarssl buffer. 所以现在我需要告诉程序调用插件的read函数,该函数不会直接从套接字读取数据,而是会从polarssl内部缓冲区读取数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM