Socket programming and other things…
by rullzer on Apr.24, 2007, under Annoying things, Daily news, Linux
So we are having this assignment at school to build a chatserver. Not to fancy. Sort of single room IRC chatserver. In the end all the written servers should be able to work together so we have a huge chatnetwork (always nice to have about 6 servers for 15 people..) But that is not the point. We choose write it in C, more specific multi threaded C. We use poll to get the CPU usage down. The only problem we have now is that when we try to be good people and close the server (so not SIGINT-ing!!!) the accept call on the socket just won’t die.
Now I know accept is blocking. But even when i close the socket accept still won’t quit. So now we are basically forced either to create a new thread. Since we can close threads. Or to make accept non blocking. We probably will go for the first one since that way a lot less CPU is used. However it really makes me wonder why you can’t interupt accept without a signal. It must be some kind of conspiracy…………. (imagine a spooky sound)




