By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,775 Members | 1,353 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,775 IT Pros & Developers. It's quick & easy.

Windows Service Project

P: n/a
I posted these on another group, but was redirected here, so here are my two
posts and my questions:

Post #1:

I've started my first practice windows service project in C#, and I'm already
stuck.

Let's say I'm trying to make a simple service (and useless, but good for
practice). It is supposed to listen on port which is stored in its configuration
file (say C:\MyService\Config.CFG). After it receives something (anything), then
it is supposed to open a file C:\MyService\File.TXT, read the number that is
written in it, increase it by 1, save it, send it to the application that
originally sent the query, close the file and wait for further queries.

In the above, there are three key moments which prevent me from programming such
a service:
1. How do I make the service listen on any port?
2. What is the event that is raised (or what do I need to do), when some query
actually arrives at that port?
3. How do I make the service send the response to an application which made the
query?

If necessary and if you can, disregard the existing standard communication
protocols, as I will be programming the client side too, so I suppose it doesn't
matter what's the format of my response.

The client, however, is another problem:
How do I make another program (I am programming it) send the query to the port
on which my service is listening, and how does it read the response?

Post #2:

While the above still isn't clear, I was using the documentation to create a
service, and put it on my services list. I've followed the tutorial
"Walkthrough: Creating a Windows Service Application in the Component Designer"
to the letter. I've installed the service and it appeared on my available
services list.

However, it failed to start. Event log only contained the following message:

Service cannot be started. The service process could not connect to the service
controller

What am I doing wrong?

Thanks,
Nikola

--
"It is easy in the world to live after the world's opinion; it easy in solitude
to live after our own; but the great man is he who in the midst of the crowd
keeps with perfect sweetness the independence of solitude."
Ralph Waldo Emerson, Self-reliance 1841
http://pinpoint.wordpress.com/

Jan 24 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Sourcerer,

You could use tons of options to listen for something. You could go
remoting, sockets. You could also go something that it is not listening by
itself, but works the way you want, like message queues.

A good reading would be:
http://www.codeproject.com/cs/internet/TCPIPChat.asp
http://www.codeproject.com/cs/intern...erandClien.asp

The very first article is pretty good and matches what you need.

I hope it helps.

--
Regards,
Robson Siqueira
Enterprise Architect
"Sourcerer" <en****@MAKNIgmail.comwrote in message
news:ep**********@ss408.t-com.hr...
>I posted these on another group, but was redirected here, so here are my
two posts and my questions:

Post #1:

I've started my first practice windows service project in C#, and I'm
already
stuck.

Let's say I'm trying to make a simple service (and useless, but good for
practice). It is supposed to listen on port which is stored in its
configuration
file (say C:\MyService\Config.CFG). After it receives something
(anything), then
it is supposed to open a file C:\MyService\File.TXT, read the number that
is
written in it, increase it by 1, save it, send it to the application that
originally sent the query, close the file and wait for further queries.

In the above, there are three key moments which prevent me from
programming such
a service:
1. How do I make the service listen on any port?
2. What is the event that is raised (or what do I need to do), when some
query
actually arrives at that port?
3. How do I make the service send the response to an application which
made the
query?

If necessary and if you can, disregard the existing standard communication
protocols, as I will be programming the client side too, so I suppose it
doesn't
matter what's the format of my response.

The client, however, is another problem:
How do I make another program (I am programming it) send the query to the
port
on which my service is listening, and how does it read the response?

Post #2:

While the above still isn't clear, I was using the documentation to create
a
service, and put it on my services list. I've followed the tutorial
"Walkthrough: Creating a Windows Service Application in the Component
Designer"
to the letter. I've installed the service and it appeared on my available
services list.

However, it failed to start. Event log only contained the following
message:

Service cannot be started. The service process could not connect to the
service
controller

What am I doing wrong?

Thanks,
Nikola

--
"It is easy in the world to live after the world's opinion; it easy in
solitude to live after our own; but the great man is he who in the midst
of the crowd keeps with perfect sweetness the independence of solitude."
Ralph Waldo Emerson, Self-reliance 1841
http://pinpoint.wordpress.com/

Jan 24 '07 #2

P: n/a
"Robson Siqueira" <ro****@robsonfelix.comwrote in message
news:OG**************@TK2MSFTNGP02.phx.gbl...
Sourcerer,

You could use tons of options to listen for something. You could go remoting,
sockets. You could also go something that it is not listening by itself, but
works the way you want, like message queues.

A good reading would be:
http://www.codeproject.com/cs/internet/TCPIPChat.asp
http://www.codeproject.com/cs/intern...erandClien.asp

The very first article is pretty good and matches what you need.

I hope it helps.
Thanks, I'll be back if I have more questions.

--
"It is easy in the world to live after the world's opinion; it easy in solitude
to live after our own; but the great man is he who in the midst of the crowd
keeps with perfect sweetness the independence of solitude."
Ralph Waldo Emerson, Self-reliance 1841
http://pinpoint.wordpress.com/

Jan 24 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.