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

Function ConnectSocketByName

src/netbase.cpp:497–531  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

495}
496
497bool ConnectSocketByName(CService& addr, SOCKET& hSocketRet, const char* pszDest, int portDefault, int nTimeout) {
498 string strDest;
499 int port = portDefault;
500 SplitHostPort(string(pszDest), port, strDest);
501
502 SOCKET hSocket = INVALID_SOCKET;
503
504 ProxyType nameproxy;
505 GetNameProxy(nameproxy);
506
507 CService addrResolved(CNetAddr(strDest, fNameLookup && !nameproxy.second), port);
508 if (addrResolved.IsValid()) {
509 addr = addrResolved;
510 return ConnectSocket(addr, hSocketRet, nTimeout);
511 }
512 addr = CService("0.0.0.0:0");
513 if (!nameproxy.second)
514 return false;
515 if (!ConnectSocketDirectly(nameproxy.first, hSocket, nTimeout))
516 return false;
517
518 switch (nameproxy.second) {
519 default:
520 case 4:
521 closesocket(hSocket);
522 return false;
523 case 5:
524 if (!Socks5(strDest, port, hSocket))
525 return false;
526 break;
527 }
528
529 hSocketRet = hSocket;
530 return true;
531}
532
533bool LookupSubNet(const char* pszName, CSubNet& ret) {
534 std::string strSubnet(pszName);

Callers 1

ConnectNodeFunction · 0.85

Calls 7

SplitHostPortFunction · 0.85
GetNameProxyFunction · 0.85
ConnectSocketFunction · 0.85
Socks5Function · 0.85
CNetAddrClass · 0.70
CServiceClass · 0.70
IsValidMethod · 0.45

Tested by

no test coverage detected