Geeks With Blogs
The Envelope Please And the Winner is...
| Home |

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.

Posted on Thursday, January 7, 2010 1:06 PM | Back to top


Comments on this post: It sucks being a newbie

# re: It sucks being a newbie
Requesting Gravatar...
You might look into the System.Threading.Timer object, initialize a new timer in OnStart. The service should finish it's start process, and the timer can perform the task of checking the port.

I'm curious what you come up with either way.

Left by Anon on Jan 07, 2010 7:29 PM

Your comment:
 (will show your gravatar)


Copyright © TheEnvelopePlease | Powered by: GeeksWithBlogs.net