non-blocking server?
Hello,
the last time I tried to write a server in C I had the problem that it had to wait for Bytes to arrive at the open port which blocked the process. A solution would be, of course, threading of the server-process or using signals, but I want this code to be used in a windows-environment, too. Is that possible? Does the standard-c-library provide some kind of signals or thread-programming for all systems?
wrazlov
Signature · 1 line
"What do you get if you multiply six by nine?"
Hy,
a more practical solution is to use the select() function, who help's you
write a server in C who can serve multiple clients at once but does not require any thread programming. And, as far as I know it's also supported by M$ C compiler and linker.
Quoted 16 lines · Wrazlov
Hello,
the last time I tried to write a server in C I had the problem that it had to wait for Bytes to arrive at the open port which blocked the process. A solution would be, of course, threading of the server-process or using signals, but I want this code to be used in a windows-environment, too. Is that possible? Does the standard-c-library provide some kind of signals or thread-programming for all systems?wrazlov
Signature · 5 lines
"What do you get if you multiply six by nine?" - To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 2 lines · Wrazlov
the last time I tried to write a server in C I had the problem that it had to wait for Bytes to arrive at the open port which blocked the process.
You can make the socket non-blocking:
fcntl(s, F_SETFL, O_NONBLOCK);
Use select() to pick the right descriptor to send()/recv() data.
Elias
Signature · 1 line
http://gnewtellium.sourceforge.net MP3 is not a crime.