While there is often very good learning going on as a newbie, when your a newbie that was on oldie (experience in another realm of coding) it can be VERY frustrating deciphering the secret handshake of manuals, error codes, etc. So, what's my problem. Well, I want to make a Windows XP service that listens to a TCP port and then, upon accepting a connection, goes off and performs a specific task. Sounds simple enough, right? Well I created a service using VS 2008. I can start, stop, pause, continue it. I have a hunk of code that initializes Winsock, creates a socket, listens on the port I want (tested this using telnet localhost port#), accepts the connection, and finally does the desired task. I am now stuck trying to integrate these two pieces of code.
Where do I put the socket code? If it's placed in the OnStart() method the for(;;) loop wont allow for the start to complete. If I put it in the constructor the service won't even start. There has to be a way to add this code into another method and instantiate that method from OnStart() and still allow the the START to complete.