开发者

For TCPListener server, Should i go for web service or windows service?

I have to develop a service which will continuously listen for broadcasted m开发者_运维百科essages over GPRS through TCPListener.

What project type should I use, Windows Service or Web Service?

If possible could you provide a short code sample?


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 tcplistener when 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/.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜