1#include "TlsStream.h" 2 3TlsStreamPtr TlsStream::connect(TlsConfig* config, const char* hostport, const char* servername) 4{ 5 TlsStreamPtr stream; 6 TlsContext context(TlsContext::kClient, config); 7 if (context.connect(hostport, servername)) 8 { 9 LOG_ERROR << context.error(); 10 return stream; 11 } 12 if (context.handshake()) 13 { 14 LOG_ERROR << context.error(); 15 return stream; 16 } 17 stream.reset(new TlsStream(std::move(context))); 18 return stream; 19} 20 21int TlsStream::receiveSome(void* buf, int len) 22{ 23 return context_.read(buf, len); 24} 25 26int TlsStream::sendSome(const void* buf, int len) 27{ 28 return context_.write(buf, len); 29} 30