Sticking a network server into a service implementation theory?
Hi everyone, I'm trying to stick a small server written with winsock into an NTService that can run under the local administrator account when the machine starts up. I've coded services, and I've coded servers....now is there a good way to mix them together? :) There could be long periods where there are no connections to the server, so I don't want the CPU pegged at 99% in a constant loop...and a client could potentially connect at any time, so I'm hesitant to have the service sleep for a period of time then periodically wake up to check connections... thanks for any advice/help
Just block in select() on the accepting socket. When there's a connection coming in, select() will un-block, showing the accepting socket as readable.
You should use select() for your readable sockets (connected clients), too, to avoid spin-waiting while clients aren't sending anything.
If you run into scalability problems, you might want to look into I/O Completion Ports on NT, but sounds like way too overkill for your needs.
You should use select() for your readable sockets (connected clients), too, to avoid spin-waiting while clients aren't sending anything.
If you run into scalability problems, you might want to look into I/O Completion Ports on NT, but sounds like way too overkill for your needs.
enum Bool { True, False, FileNotFound };
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement