Winsock system proxy settings

I have a simple winsock program and I want to stream my connection through the system proxy. I saw a post that explains how to catch the system proxy and then send a string like below:

CONNECT 127.0.0.1:8080 HTTP/1.0\r\n

      

etc. But it doesn't work exactly all the time. On the other hand, when using WinInet API (InternetOpen () function and ...) it works great. I need a solution like WinInet that always works correctly and bi-directional functionality like Winsocket.

+3


source to share


1 answer


There is no such thing as a "system proxy". The WinInet proxy settings are part of WinInet, not Windows itself (Internet Explorer uses WinInet, so WinInet settings affect IE but not WinSock).

CONNECT 127.0.0.1:8080 HTTP/1.0\r\n\r\n

is a connection string for creating a tunnel through an HTTP proxy server (see Tunneling with HTTP CONNECT ). You connect to the proxy server, send a command CONNECT

to connect to the target server, check the response, and if successful, you can perform bi-directional communication with the target server as if you were directly connecting to it.



But there are other types of proxies like SOCKS . Same concept (connect to proxy, request connection to target, continue fine after that), but very different from HTTP.

When coding with WinSock, you need to implement various proxy protocols manually in your own code, or find a third party library to handle it. WinSock does not have built-in proxy support. And you must know in advance what type of proxy is used, so you can use the correct protocol. There are APIs to dynamically define proxy settings, or just ask the user for data.

+2


source







All Articles