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

I am writing proxies using .NET and C #. I didn't program much on Socket, and I'm not sure if this is the best way. What would be the best way to implement this? Should I use synchronous sockets, asynchronous sockets? Please, help!

He must...

  • Accept connections from the client to two different ports, and receive data on both ports at the same time.
  • Connect to the server on two different ports and you can send data to both ports at the same time.

  • Connect to the server immediately and start forwarding packets as soon as the client is connected.

  • Forward packets in the same order in which they were received.

  • Be as low as possible latency.

  • I do not need the ability for several clients to connect to a proxy server, but it would be nice if its easy to implement.

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

+3
source share
2 answers

I was already messing around with this source code . This was done well, recommended.

+3
source

, PortFusion! , - all TCP. .NET 4.0 .

ReceiveAsync SendAsync, .NET 3.5, , , - Async .

: : async

+1

Source: https://habr.com/ru/post/1740743/


All Articles