MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / ConnectSocket

Function ConnectSocket

src/netbase.cpp:465–495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

463int GetConnectTime() { return SysCfg().GetConnectTimeOut(); }
464
465bool ConnectSocket(const CService& addrDest, SOCKET& hSocketRet, int nTimeout) {
466 ProxyType proxy;
467
468 // no proxy needed
469 if (!GetProxy(addrDest.GetNetwork(), proxy))
470 return ConnectSocketDirectly(addrDest, hSocketRet, nTimeout);
471
472 SOCKET hSocket = INVALID_SOCKET;
473
474 // first connect to proxy server
475 if (!ConnectSocketDirectly(proxy.first, hSocket, nTimeout))
476 return false;
477
478 // do socks negotiation
479 switch (proxy.second) {
480 case 4:
481 if (!Socks4(addrDest, hSocket))
482 return false;
483 break;
484 case 5:
485 if (!Socks5(addrDest.ToStringIP(), addrDest.GetPort(), hSocket))
486 return false;
487 break;
488 default:
489 closesocket(hSocket);
490 return false;
491 }
492
493 hSocketRet = hSocket;
494 return true;
495}
496
497bool ConnectSocketByName(CService& addr, SOCKET& hSocketRet, const char* pszDest, int portDefault, int nTimeout) {
498 string strDest;

Callers 4

ConnectSocketByNameFunction · 0.85
GetMyPublicIPFunction · 0.85
PostNodeInfoFunction · 0.85
ConnectNodeFunction · 0.85

Calls 6

GetProxyFunction · 0.85
Socks4Function · 0.85
Socks5Function · 0.85
GetNetworkMethod · 0.80
ToStringIPMethod · 0.80
GetPortMethod · 0.80

Tested by

no test coverage detected