3

This requires discussion for best practices related to server development using C++ on Windows 7 32-bit

The typical requirements:

  1. A program that acts like a "server", running in Windows in the background. It should run for days, should run automatically at each start.
  2. Server Handles incoming client connections via TCP socket protocol from other devices (PC,Smartphone,tablets)
  3. Server in-turn communicating with large number of embedded devices connected in same network via TCP and serial communications
  4. Server acting as bridge b/w clients (PC, smartphone, tablets) and embedded devices

The server admin can configure server through the configuration .ini file and then can start server.

The interface to the client end is TCP socket interface, client will send command and server inturn will reply with buffer (xml) My questions:

  1. Should I write the program as a "service", like http://code.msdn.microsoft.com/windowsdesktop/CppWindowsService-cacf4948

  2. Or should i write a console application and control this executable from XYNTService http://mysite.verizon.net/XiangYangL/XYNTService.htm so that it acts like a service

  3. Or a console application , with it's entry in registry for starting at login, restart

Does this actually matter, which option to choose from above ?

Many Thanks in advance.

Rohit
  • 6,941
  • 17
  • 58
  • 102
  • 4
    If it quacks like a service then it is a service. You haven't specified any interaction with user, which is most important factor in "is it a service" question IMHO. The page about XYNT targets NT4.0, so I suspect it's about 16 years old. No point in archeology. – Agent_L Jan 10 '13 at 13:10
  • 2
    Like a service. But a command line option to run like a console app may be useful for development and debugging efficiency. – selbie Jan 10 '13 at 13:21
  • 1
    I agree with @selbie. I have wrote many services and I couldn't imagine any other way of working efficiently. – ixe013 Jan 10 '13 at 13:42
  • so, initially we should make console executable and later on we enable the service module in the same. I mean making code in such a way that it can act as a executable while debugging and service while deploying. ? – Rohit Jan 10 '13 at 14:02
  • Gets my vote; Console app with command line to enable it otherwise it becomes a service. – Russ Freeman Jan 10 '13 at 14:05
  • Is there a pressing need to write this in C++? It'd be a lot easier in C#. Perhaps a bit self-serving, but here you go: http://stackoverflow.com/questions/593454/easiest-language-for-creating-a-windows-service/593803#593803 – Matt Davis Jan 10 '13 at 14:13
  • @Marc Gravell provides some key insights for installing and executing a C#-based service here: https://groups.google.com/forum/?hl=en&fromgroups=#!topic/microsoft.public.dotnet.languages.csharp/TUXp6lRxy6Q – Matt Davis Jan 10 '13 at 14:17
  • currently preferring C++ as we might shift to linux later – Rohit Jan 11 '13 at 05:04

1 Answers1

0

This is exactly the use case for which services are intended, so make it a service.

For easier debugging, add a command line option to start it as a console process.

oefe
  • 19,298
  • 7
  • 47
  • 66
  • Made it Community Wiki as I'm essentially only summarizing the answers that were already given in the comments. – oefe Nov 10 '13 at 08:03