简体   繁体   English

C / C ++ SOCKET代理

[英]C/C++ SOCKET Proxy

Currently, I implemented a client and server application which use simple SOCKETs to communicate with each other. 当前,我实现了一个客户端和服务器应用程序,它们使用简单的SOCKET相互通信。 Like this . 这样

The problem is that some users don't have a direct access to the internet, so they use proxys. 问题在于某些用户无法直接访问Internet,因此他们使用代理。

How can I use SOCKETs for a communication over a proxy (eg default IE proxy), or is there any other possibility? 如何使用SOCKET通过代理(例如默认的IE代理)进行通信,或者还有其他可能性吗?

First and foremost, there are different types of proxies and different types of protocols used by those proxies. 首先,存在不同类型的代理以及这些代理使用的不同类型的协议。 There are HTTP proxies, SOCKS proxies, Tunneling proxies, etc. So first you need to decide what type(s) of proxies you want to support in your code, and then implement each of those protocols as needed. 有HTTP代理,SOCKS代理,隧道代理等。因此,首先需要确定要在代码中支持的代理类型,然后根据需要实现每个协议。

In general, instead of connect() 'ing directly to the desired server, the client would connect() to a proxy server instead and instruct it to connect to the server, using whatever protocol that proxy uses. 通常,客户端不是将connect()直接连接到所需的服务器,而是将connect()到代理服务器,并指示其使用代理使用的任何协议连接到服务器。 Once that connection has been established, the rest of the client and server code would send() and recv() data normally as it already is, and the proxy would transparently exchange the data back and forth. 一旦建立了连接,其余的客户端和服务器代码将正常send()recv()数据,并且代理将透明地来回交换数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM