Kin
Kin

Reputation: 1397

C# Proxy using Sockets, how should I do this?

I'm writing a proxy using .NET and C#. I haven't done much Socket programming, and I am not sure the best way to go about it. What would be the best way to implement this? Should I use Synchronous Sockets, Asynchronous sockets? Please help!

It must...

Client --------- Proxy ------- Server
---|-----------------|----------------|
Port <--------> Port <-------> Port
Port <--------> Port <-------> Port

Upvotes: 3

Views: 5102

Answers (2)

Cetin Sert
Cetin Sert

Reputation: 4590

Please check out PortFusion! It is a complete, actively-used and -developed distributed reverse proxy solution for all TCP-based traffic. It is written for .NET 4.0 and comes with full source code.

I have tested ReceiveAsync and SendAsync methods introduced in .NET 3.5 but have not found them to reach as high a throughput as is possible with synchronous ones - Async ones should scale better in case of a great number of concurrent clients though.

Maximum throughput for a controlled number clients: use synchronous methods Reaching maximum number of concurrent connections: async

Upvotes: 1

Hans Passant
Hans Passant

Reputation: 941218

I've tinkered with this source code before. It was done well, recommended.

Upvotes: 3

Related Questions