Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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...

  • Accept Connections from the client on two different ports, and be able to receive data on both ports at the same time.
  • Connect to the server on two different ports, and be able to send data on both ports as the same time.

  • Immediately connect to the server and start forwarding packets as soon as a client connection is made.

  • Forward packets in the same order they were received.

  • Be as low latency as possible.

  • I don't need the ability for multiple clients to connect to the proxy, but it would be a nice feature if its easy to implement.

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

like image 516
Kin Avatar asked Mar 11 '26 03:03

Kin


1 Answers

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

like image 139
Hans Passant Avatar answered Mar 12 '26 16:03

Hans Passant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!