MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / _openSocket

Function _openSocket

cpp/src/platform/HttpClient.cpp:478–518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

476}
477
478static bool _openSocket
479(
480SOCKET *ps,
481const char *host,
482unsigned port
483)
484{
485#ifdef MINIHTTP_USE_POLARSSL
486 int s;
487 int err = net_connect(&s, host, port);
488 if(err)
489 {
490 traceprint("open_ssl: net_connect(%s, %u) returned %d\n", host, port, err);
491 return false;
492 }
493#else
494 sockaddr_in addr;
495 if(!_Resolve(host, port, &addr))
496 {
497 traceprint("RESOLV ERROR: %s\n", _GetErrorStr(_GetError()).c_str());
498 return false;
499 }
500
501 SOCKET s = socket(AF_INET, SOCK_STREAM, 0);
502
503 if(!SOCKETVALID(s))
504 {
505 traceprint("SOCKET ERROR: %s\n", _GetErrorStr(_GetError()).c_str());
506 return false;
507 }
508
509 if (::connect(s, (sockaddr*)&addr, sizeof(sockaddr)))
510 {
511 traceprint("CONNECT ERROR: %s\n", _GetErrorStr(_GetError()).c_str());
512 return false;
513 }
514#endif
515
516 *ps = s;
517 return true;
518}
519
520#ifdef MINIHTTP_USE_POLARSSL
521void traceprint_ssl

Callers 1

openMethod · 0.85

Calls 4

_ResolveFunction · 0.85
_GetErrorStrFunction · 0.85
_GetErrorFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected