Closed jmevel closed 1 year ago
You missed the line above registering the connection with epoll:
let fd = connection.as_raw_fd();
let event = Event::new(Events::EPOLLIN | Events::EPOLLOUT, fd as u64);
// ...
The fd == listener.as_raw_fd()
check simply tells us if the event was for TCP listener readiness, i.e. an incoming connection, as opposed to a TCP connection becoming ready in the map.
Ahhhh I missed the variable shadowing !!! Makes perfect sense now.
Thanks again !
Hi,
Still (slowly) following your blog post but there's a piece I don't understand in the
multiplexed server
section.You are doing
What does
if fd == listener.as_raw_fd()
do exactly? Obviously iffd
andlistener.as_raw_fd()
were identical then this would work the same:But actually it doesn't. We get a crash with the following error message:
Which makes sense because we already added this file descriptor above the main
loop
So how is this
if fd == listener.as_raw_fd()
working? I'm confused.Thanks for your answer 🙏