Could You Recommend Some Guides About Epoll on Linux

Could you recommend some guides about Epoll on Linux

Here's an introduction to Epoll, a pretty basic tutorial: http://blog.kovyrin.net/2006/04/13/epoll-asynchronous-network-programming/

A more complete example can be found here: https://banu.com/blog/2/how-to-use-epoll-a-complete-example-in-c/

Also, the man pages

Can a single Epoll fd be used to watch events on different types of sockets?

epoll, poll and select were designed to monitor multiple file descriptors. It doesn't limit of monitoring only one instance of file / socket descriptors at any time.

is can one Epoll instance be used to track events on both tcp sockets and unix domain sockets?
Yes, there is no specific limit on using epoll.

Have a look of sample epoll program at Could you recommend some guides about Epoll on Linux

EPoll C Implementation that I can call from Java through JNI

You can find epoll sample program written in C by me. I hope that will help you Could you recommend some guides about Epoll on Linux

Most efficient way to handle a client connection (socket programming)

the infinite loop in those examples is already efficient. the call to accept() is a blocking call: the function does not return until there is a client connecting to the server. code execution for the thread which called the accept() function is halted, and does not take any processing power.

think of accept() as a call to join() or like a wait on a mutex/lock/semaphore.

of course, there are many other ways to handle incoming connection, but those other ways deal with the blocking nature of accept(). this function is difficult to cancel, so there exists non-blocking alternatives which will allow the server to perform other actions while waiting for an incoming connection. one such alternative is using select(). other alternatives are less portable as they involve low-level operating system calls to signal the connection through a callback function, an event or any other asynchronous mechanism handled by the operating system...

What is a good book/guide for socket programming in C?

UNIX Network Programming, Volume 1, Second Edition: Networking APIs: Sockets and XTI.

Then go from there.



Related Topics



Leave a reply



Submit