473,320 Members | 1,612 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Creating a "listening" program

SH
I wish to create a program (really a Windows Service) that sits and
waits for a client PC to communicate with it, but I can't come up with a
good method of doing so.

I want to have a service running on a server, waiting for clients to
send it commands. The service would then do something based on the
command and send the information back to the client. This is exactly
what any database does. What is the best method for doing this?

The only method I can come up with, is that when the client wishes to
communicate with the service it would write a file on the server. The
service would check for the existence of that file every X number of
seconds. Then the service would do it's thing and write back another
file with the results. The client would constantly check every X number
of seconds for the existence of the results file and then read the file.

I, of course, don't like this solution. It's not elegant, it avoids the
whole point, and I can see timing problems throughout.

Is there another way for a service to just "listen" for a stream of data
directly without a file intermediary? What command just "listens"? And
how do you receive a stream of data out of thin air?

Thanks for any ideas.
Nov 23 '05 #1
4 2333
SH wrote:
I wish to create a program (really a Windows Service) that sits and
waits for a client PC to communicate with it, but I can't come up with a
good method of doing so.

I want to have a service running on a server, waiting for clients to
send it commands. The service would then do something based on the
command and send the information back to the client. This is exactly
what any database does. What is the best method for doing this?

The only method I can come up with, is that when the client wishes to
communicate with the service it would write a file on the server. The
service would check for the existence of that file every X number of
seconds. Then the service would do it's thing and write back another
file with the results. The client would constantly check every X number
of seconds for the existence of the results file and then read the file.

I, of course, don't like this solution. It's not elegant, it avoids the
whole point, and I can see timing problems throughout.

Is there another way for a service to just "listen" for a stream of data
directly without a file intermediary? What command just "listens"? And
how do you receive a stream of data out of thin air?

Thanks for any ideas.


You can create a socket that listens on a specific port (in a windows
service). When that socket is connected to you can do whateever you
want on the server. You can do this through remoting as well.

Chris
Nov 23 '05 #2
SH
Thanks, Chris. I don't know how to do any of this. Can you point me to
any articles, code, etc about creating sockets and using them.

Chris wrote:
SH wrote:
I wish to create a program (really a Windows Service) that sits and
waits for a client PC to communicate with it, but I can't come up with
a good method of doing so.

I want to have a service running on a server, waiting for clients to
send it commands. The service would then do something based on the
command and send the information back to the client. This is exactly
what any database does. What is the best method for doing this?

The only method I can come up with, is that when the client wishes to
communicate with the service it would write a file on the server. The
service would check for the existence of that file every X number of
seconds. Then the service would do it's thing and write back another
file with the results. The client would constantly check every X
number of seconds for the existence of the results file and then read
the file.

I, of course, don't like this solution. It's not elegant, it avoids
the whole point, and I can see timing problems throughout.

Is there another way for a service to just "listen" for a stream of
data directly without a file intermediary? What command just
"listens"? And how do you receive a stream of data out of thin air?

Thanks for any ideas.

You can create a socket that listens on a specific port (in a windows
service). When that socket is connected to you can do whateever you
want on the server. You can do this through remoting as well.

Chris

Nov 23 '05 #3
http://www.codeproject.com/vb/net/Silence_Socket.asp

quick and easy async socket help
--
-iwdu15
Nov 23 '05 #4
SH,
I have not done the socket route but I have created something like this
using .NET Remoting. What you'll need is to create an assembly in which you
have defined an interface. In this interface you'll have a method that takes
a parameter, perhaps the command that the user passes.
Create the remoting server. Create a class in this remoting server that
inherits from MarshalByRefObject and implements the interface you defined in
the other assembly. When you start up your service, create the TcpChannel or
HttpChannel (whichever you want, Tcp is faster) with an appropriate port and
register the channel using ChannelServices.RegisterChannel and then
RegisterWellKnownServiceType using RemotingConfiguration using the class
that you created in your service application that implements your interface.

In the client, reference the assembly that contains your interface with the
method call and get an object of that type using Activator.GetObject setting
up the ip address and port to be used. Once you have the object, call the
method passing in the command and get its returned data. That's pretty much
it. You should be able to find ample examples of this using Google also.

HTH
Steve
"SH" <sh*****@prupipe.com> wrote in message
news:De*****************@newsread3.news.pas.earthl ink.net...
Thanks, Chris. I don't know how to do any of this. Can you point me to
any articles, code, etc about creating sockets and using them.

Chris wrote:
SH wrote:
I wish to create a program (really a Windows Service) that sits and
waits for a client PC to communicate with it, but I can't come up with
a good method of doing so.

I want to have a service running on a server, waiting for clients to
send it commands. The service would then do something based on the
command and send the information back to the client. This is exactly
what any database does. What is the best method for doing this?

The only method I can come up with, is that when the client wishes to
communicate with the service it would write a file on the server. The
service would check for the existence of that file every X number of
seconds. Then the service would do it's thing and write back another
file with the results. The client would constantly check every X
number of seconds for the existence of the results file and then read
the file.

I, of course, don't like this solution. It's not elegant, it avoids
the whole point, and I can see timing problems throughout.

Is there another way for a service to just "listen" for a stream of
data directly without a file intermediary? What command just
"listens"? And how do you receive a stream of data out of thin air?

Thanks for any ideas.

You can create a socket that listens on a specific port (in a windows
service). When that socket is connected to you can do whateever you
want on the server. You can do this through remoting as well.

Chris

Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Jako Menkveld | last post by:
I'm building a relatively simple client-server app. One of the functions of the client is to notify the server when it terminates, this all works fine. The problem comes in when the server is...
3
by: ssantamariagarcia | last post by:
I am trying to program a server in C for UNIX to get a kind of "bridge" between the clients of a port A and the clients of a port B. For that, I create 2 processes: one that listen the requests of...
7
by: Adam Clauss | last post by:
I am trying to work-around a firewall which limits me to only being able to accept inbound connections on port 80. Unfortunately, I need to two different applications to be able to accept...
1
by: Dr. J | last post by:
I have an application that opens a socket and connects to another application listening over a port. The problem I am encountering is that when the listening application is closed my application...
0
by: Dave L | last post by:
I just upgraded from VS .NET 2002 to 2003. Everything built okay, but strange bugs started appearing. Apparently there is a bug in the managed C++ compiler in regards to handling of static...
45
by: Gregory Petrosyan | last post by:
1) From 2.4.2 documentation: There are two new valid (semantic) forms for the raise statement: raise Class, instance raise instance 2) In python: >>> raise NameError Traceback (most recent...
2
by: ppuniversal | last post by:
hello, my program snippet: /*****************************/ /******runThread Function*****/ /*to accept other client connections*/ /*****************************/ DWORD WINAPI...
8
by: clyfish | last post by:
In cmd, I can use find like this. C:\>netstat -an | find "445" TCP 0.0.0.0:445 0.0.0.0:0 LISTENING UDP 0.0.0.0:445 *:* C:\> And os.system is OK....
17
by: John Salerno | last post by:
Let me see if this question even makes sense...I'm reading Core Python Programming and I jumped ahead to the more specific topics like network programming. I plan to follow along with the example...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.