简体   繁体   English

Tcp服务器使用Wcf服务

[英]Tcp Server Using Wcf Service

I am an experienced C# developer, but I have not developed a TCP server application so far. 我是一名经验丰富的C#开发人员,但到目前为止我还没有开发过TCP服务器应用程序。 Now I have to develop a highly scalable and high performance server that can handle at least 5-10 thousand concurrent connections: getting -raw byte- data via GPRS from GPS devices. 现在我必须开发一个高度可扩展的高性能服务器,它可以处理至少5-10万个并发连接:通过GPRS从GPS设备获取字节数据。

A common communication process should look like this: 常见的通信过程应如下所示:

GPS device initiates a connection to my server my server answers if I want to get data device send GPS data my server sends report to the device about getting it (sg like checksum) getting new data from GPS, reportm and this happens again and again later GPS DEVICE closes the connection So, in my server I need GPS设备启动与我的服务器的连接我的服务器应答如果我想让数据设备发送GPS数据我的服务器向设备发送关于获取它的报告(例如校验和)从GPS获取新数据,报告并且这种情况一次又一次地发生GPS设备关闭连接因此,在我需要的服务器中

trace connected/active clients to close any client from server side catch the event, when a device closes the connection get byte data send data to clients I started to read about this topic over the internet, but it seems to be a nightmare for me. 跟踪连接/活动客户端从服务器端关闭任何客户端捕获事件,当设备关闭连接时获取字节数据发送数据给客户端我开始通过互联网阅读有关此主题的信息,但这对我来说似乎是一场噩梦。 There are a lot of ways, but I could not find out which is the best. 有很多方法,但我找不出哪个是最好的。

Async socket methods seems the best for me, but writing code in this async style is terrible and not easy to debug. 异步套接字方法对我来说似乎是最好的,但是以这种异步方式编写代码非常糟糕且不易调试。

So my quetsion is: which do you think the best way to implement a high performance TCP server in C#? 所以我的观点是:您认为在C#中实现高性能TCP服务器的最佳方式是什么? Do you know any good open source component to do this? 你知道有什么好的开源组件吗? (I tried several ones, but I could not find a good one.) (我尝试了几个,但我找不到一个好的。)

Thanks in advance, any expert answers would be appriciated! 在此先感谢,任何专家的答案都会得到满足!

Two suggested ideas you can use. 您可以使用两个建议的想法。

  1. WCF TCP (Duplex?) - Here you can have an async pattern, where both the client and the server can call each other. WCF TCP(双工?) - 在这里你可以有一个异步模式,客户端和服务器都可以互相调用。 Defintely needs some plumbing involved, but there is lots of documentation out there. 绝对需要一些管道,但有很多文档。

  2. RESTFUL - I think this may be the better option for you. RESTFUL - 我认为这对你来说可能是更好的选择。 This is VERY easy to make async, and because of REST's stateless nature there is much less overhead. 这非常容易实现异步,并且由于REST的无状态特性,所以开销更少。 FYI, you can use TCP for this, although HTTP would probably be the better choice. 仅供参考,您可以使用TCP,尽管HTTP可能是更好的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM