使用Socket的C#代理,该怎么办? [英] C# Proxy using Sockets, how should I do this?

查看:52
本文介绍了使用Socket的C#代理,该怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用.NET和C#编写代理.我没有做太多的Socket编程,而且我不确定执行此操作的最佳方法.实施此方法的最佳方法是什么?我应该使用同步套接字,异步套接字吗?请帮忙!

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!

必须...

  • 接受来自客户端的连接两个不同的端口,并能够在两个端口上的两个端口上接收数据同时.
  • 在两个不同的端口上连接到服务器,并能够同时在两个端口上发送数据.

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

保持尽可能低的延迟.

我不需要多重能力客户端连接到代理,但是如果容易的话将是一个不错的功能实施.

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

推荐答案

我已经修改此源代码之前.建议做得很好.

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

这篇关于使用Socket的C#代理,该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆