tags:

views:

41

answers:

2

i have created the socket program to run in win32 service but the problem i'm facing is that when i start the service it'll start and it is using CPU move its all most 50% of the CPU. i'm using AMD 64bit processor.

if i write a program without socket it wont use CPU as much.

wat should i do to solve this problem.

+2  A: 

You probably need to look at something like select(), to block when waiting for data to read.

Without more detail, it's hard to tell exactly what your problem is, but it's likely to be something like that.

unwind
A: 

Yeah, a piece of sample code would help, but the problem is most likely that you're in a timeout loop. Depending on which side of the client/server connection you're on, this could be solved by either calling accept() or select() with an infinite timeout. In practice, it's better to have a long timeout, on the order of a second, so the process/thread can look for a signal and shut down if requested.

jfawcett