
VC++ network request to hang proxy IP wild teaching
Big brothers do network development, certainly encountered to change the IP of the scene. Today, we will teach you to use VC++ to hook up the proxy IP to the program, take our domesticipipgoServices come to hands-on demonstrations.
I. Why Proxy IP?
To give a chestnut: you write the automatic sign-in program is always blocked by the website IP, this time you need to change the vest (proxy IP). It is like playing a game to open a small number, change the IP address can continue to wave. Be careful not to take it to do bad things, we are serious technical exchanges!
II. WinINet Library Configuration Agent
The most commonly used VC++ is the WinINet library, directly on the hard dishes:
HINTERNET hSession = InternetOpen(
L "MyApp/1.0",
INTERNET_OPEN_TYPE_PROXY, L "http=114.55.66.77:8080", //switch to ipipgo.
L "http=114.55.66.77:8080", //replace with the IP and port given by ipipgo
NULL,
0
);
There's a pit here:Proxy string format must be strictly protocol=IP:portThe proxy of ipipgo supports HTTP/HTTPS/Socks5 proxy. For example, if you use socks5 proxy, you can write "socks5=121.202.12.34:1080″. ipipgo's proxy supports HTTP/HTTPS/Socks5 protocols, so don't get confused.
Dynamic switching agents in practice
Want a different proxy for each request? Watch this tawdry operation:
std::vector proxyList = {
L "http://user:pass@45.76.89.1:8080", //dynamic residential proxy format for ipipgo
L "http://user:pass@203.23.45.6:3128".
L "http://user:pass@87.98.76.5:8888"
};
// Pick a random vest each time
srand(time(NULL));
std::wstring currentProxy = proxyList[rand() % proxyList.size()];
// Set the proxy
InternetSetOption(
hSession, hSession_Options_Internet_Options_Control
INTERNET_OPTION_PROXY, ¤tProxy, hSession
hSession, INTERNET_OPTION_PROXY, ¤tProxy, sizeof(currentProxy)
sizeof(currentProxy)
);
take note ofUsername and password should be replaced with the authentication information of the ipipgo account, their agents are required to have account authentication.
IV. Common rollover site treatment
Q: Proxy settings are successful but I can't connect?
A: First check the three elements: whether the IP is valid, the port is correct, the protocol type matches. Use the test tool that comes with the ipipgo client to save time.
Q: The program is suddenly stuck as a dog?
A: It may be that the proxy server is slow to respond to suggestions:
1. Setting the timeout: InternetSetOption sets the timeout parameter
2. change ip ipgo exclusive static ip package, 35 yuan a ip with a whole month
V. Why do you recommend ipipgo?
There are three agents in this house:
1. Global 200+ countries IP cut casually, overseas business is not false.
2. Support pay per volume, more than 7 yuan 1G traffic enough to play a few days
3. The client comes with a speed test function, which node is fast at a glance
Beginners are advised to start withDynamic Residential Standard, $7.67/GB is enough to toss around. Enterprise level projects go straight to a dedicated IP to avoid grabbing bandwidth with others.
VI. Guidelines for avoiding pitfalls
1. Don't create/close sessions repeatedly in a loop, it's a memory leak.
2. To set the proxy type to INTERNET_OPEN_TYPE_PROXY when handling HTTPS requests.
3. use ipipgo's API to get the latest proxy list, don't write IPs to death in the code
Lastly: Proxy IP is not a talisman, don't mess with HF requests. If you want to do serious business, it is recommended to buy a customized solution from ipipgo, their technical guys can help you tune the configuration.

