Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have some problems in my web service .
As we all know, the web service is just a service on a database that I ask for using some interface and it returns the answer to me.

I want to make a webservice on the database that has a function that runs forever.
This function checks for input on a certain tcp port, does something if there is data on it and sends a response to the sender.
This function must run forever .

Is it possible with a webservice?

If not, what is the solution of this problem that I want to make an interface on a database and have a function that runs forever?
Posted
Updated 11-Jan-11 21:25pm
v3
Comments
Sandeep Mewara 12-Jan-11 3:34am    
So what do you want? Pass the value somewhere using webservice automatically?
Couldn't make out where you need this WS to play a role. Functions runs in DB, right?
Sandeep Mewara 12-Jan-11 4:12am    
Moved OP's update:
sandeep mewara

thank you for your answer

i want a webservice that has a function that run forever without need to invoke it, this function check the tcp port forever

From the question what I understood is you need a Windows service to check the value in the TCP/IP port. Web service need to be invoked always.
If you want the Web service to do the checking use the windows service to invoke the web service , which ( Web Service) in turn do the checking and sending of data in TCP/IP port ( this is not a good way to do )
 
Share this answer
 
v2
Comments
amir tarek 12-Jan-11 4:18am    
thank you mab_j for that but can you give me c# code example for windows service that invoke web service?
Baji Jabbar 12-Jan-11 4:24am    
Sandeep has given you the links. Just refer it and do it by yourself. In my code db I don't have the code which you want :). Try and do it by yourself first and then if stuck in somewhere feel free to post , CP has lot of kind heart helping peoples , who is eager to help someone ;) , surely someone or many will show you the correct way to solve the issue
"i want a webservice that has a function that run forever without need to invoke it, this function check the tcp port forever"

There is a way for it. Create a windows service and let it run 'forever'.
Internally, refer the webservice. Ping/use the webservice function at defined interval like 5 sec or 1 min or x min. This would lead you to run the function automatically for given time.

Have a look here of how to create a windows service:
Simple Windows Service Sample[^]
Windows Services in Action I[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900