3 ms·
I think the answer is actually pretty straightforward. It's trivial to go from a serial to a threaded server. It's way harder to write an event-based server u
by alexgartrell 16y ago
I think the answer is actually pretty straightforward. It's trivial to go from a serial to a threaded server. It's way harder to write an event-based server using poll or select.
Serially:
int handle_connection(int fd) {
...
}
int loop() {
...
while(1) {
fd = accept(listener);
handle_connection(fd);
}
}
Threaded:
int handle_connection(int fd) {
...
}
int loop() {
...
while(1) {
fd = accept(listener);
thread_start(handle_connection, fd);
}
}
- sovande 16y agoNo its not. Using your contrived limited example its even less code. Evented: int handle_connection(int fd) { ... } int doaccept() { put_on_event_loop(accept(listener)); }