TCP/IP server - Windows Service vs. application

  • Thread starter Thread starter Josh Salit
  • Start date Start date
J

Josh Salit

Hi,
I'm working with a TCP/IP server (Mixed C/C++, built with VC++ .NET
2002) that can be run as either an application or as a Windows Service.
The problem we are facing is that when running as an application, the
server can handle 15+ connection attempts at relatively the same time.
When the program is run as a Service, however, it can't seem to handle
more than 4 at a time...We end up having to throttle the incoming
connections in order to have them all accepted properly.

My basic question is this: Is there any reason (typical Windows
2000/XP/2003 behavior, registry settings, etc) that a server program
should perform so differently when running as a Windows Service as
compared to when running as a normal application?

listen() is being passed SOMAXCONN as it's second argument, and after
accept() is called, only a few (small) memory allocations are performed
before passing the socket off to handler thread.

Any advice or ideas would be appreciated...

Thanks,
Josh
 
Josh Salit said:
My basic question is this: Is there any reason (typical Windows
2000/XP/2003 behavior, registry settings, etc) that a server program
should perform so differently when running as a Windows Service as
compared to when running as a normal application?

I can't think of one.

Are you running the tests on the same box? I ask because 4 is close to 5 <g>
and 5 is (I think) the maximum number of simultaneous connections allowed by
some NT licenses.

Regards,
Will
 
William said:
I can't think of one.

Are you running the tests on the same box? I ask because 4 is close to 5 <g>
and 5 is (I think) the maximum number of simultaneous connections allowed by
some NT licenses.

Will,
Yes, the tests are run on the same box. The only limit I know of is the
backlog implemented by listen(), which I believe is limited to 5, but
that begs the question of why should the program's speed in accepting
the connections and passing them off to a handler thread differ when
running as a Service compared to as an application?

thanks,
Josh
 
Josh Salit said:
but
that begs the question of why should the program's speed in accepting
the connections and passing them off to a handler thread differ when
running as a Service compared to as an application?

Right. That's the question. :-)

Seriously, I can see how initialization and termination could be different,
but once the service gets going, it should be executing the same code as in
the console application case. What _is_ different is the runtime
environment: a different user context, a different desktop etc

This article is provides a good overview of the kinds of things that can
bite you in a service:

http://www.microsoft.com/msj/0398/service2.aspx

Perhaps it will help.

Regards,
Will
 
Back
Top