I have to develop a service which will continuously listen for broadcasted messages over GPRS through TCPListener.
What project type should I use, Windows Service or Web Service?
If possible could you provide a short code sample?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The term “Web services” usually refers to systems that listen for standard HTTP requests on port 80, most generally using SOAP, JSON or plain-old-XML. Microsoft offer several frameworks to publish and consume Web services in .NET, including WCF, IIS and rolling your own through
tcplistener.A “Windows service” is a long-lived process that can be started automatically when the system starts. A service doesn’t itself have any intrinsic mechanism for communication: you’ll have to write that yourself.
So you’ll want to consider what kind of communication protocol your GPRS system is going to use. If it’s broadcasting a high-level series of e.g. HTTP POST data, then a WCF endpoint hosted on IIS is probably the easiest and quickest way to go.
Alternatively, if your GPRS system is doing low-level broadcasts of TCP packets over a known port, you’ll most likely want to create a Windows service, and then create a
tcplistenerwhen the service starts.The Visual Studio wizard to create a Windows service will give you the scaffolding necessary to create code that executes when the service starts. There’s a good walkthrough here: http://www.csharp-examples.net/create-windows-service/.