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

Method open

cpp/src/platform/HttpClient.cpp:570–638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

568#endif
569
570bool TcpSocket::open
571(
572const char *host,
573unsigned int port
574)
575{
576 if(isOpen())
577 {
578 if( (host && host != _host) || (port && port != _lastport) )
579 close();
580 // ... and continue connecting to new host/port
581 else
582 return true; // still connected, to same host and port.
583 }
584
585 if(host)
586 _host = host;
587 else
588 host = _host.c_str();
589
590 if(port)
591 _lastport = port;
592 else
593 {
594 port = _lastport;
595 if(!port)
596 return false;
597 }
598
599 traceprint("TcpSocket::open(): host = [%s], port = %d\n", host, port);
600
601 assert(!SOCKETVALID(_s));
602
603 _recvSize = 0;
604
605 {
606 SOCKET s;
607 if(!_openSocket(&s, host, port))
608 return false;
609 _s = s;
610
611#ifdef SO_NOSIGPIPE
612 // Don't fire SIGPIPE when trying to write to a closed socket
613 {
614 int set = 1;
615 setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int));
616 }
617#endif
618
619 }
620
621 _SetNonBlocking(_s, _nonblocking); // restore setting if it was set in invalid state. static call because _s is intentionally still invalid here.
622
623#ifdef MINIHTTP_USE_POLARSSL
624 if(_sslctx)
625 {
626 traceprint("TcpSocket::open(): SSL requested...\n");
627 if(!_openSSL(&_s, (SSLCtx*)_sslctx))

Callers

nothing calls this directly

Calls 4

_openSocketFunction · 0.85
_SetNonBlockingFunction · 0.85
_openSSLFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected