High performance TCP Client in .net

2019-05-31 05:51发布

问题:

A lot of the good posts on .Net sockets seen on SO are around writing scalable high performance servers.

High performance TCP server in C#

How to write a scalable Tcp/Ip based server

While those posts are very good, what are the core things to focus on when writing high performance TCP Client Applications?

A scenario for a high performance client would be an application that streams requests to a server and processes responses in a non-blocking fashion.

Such a client should also have a strategy for reliable disconnect detection.

To further clarify, we have no control over the server end.

We simply have a server endpoint to connect to.

zmqNet mentioned in the comments is a great lib, but I think its strongest (or meant for cases) where both ends of the connection are using zmq (true?).

回答1:

Go with netMQ (0MQ). It's available as a NuGet package so that should be easy to maintain.

I'd suggest something like a client-side request socket and a router/dealer construction on the server side. The documention providere here: http://zguide.zeromq.org/page:all is excellent.