You.i Engine
CYITCPSecureSocket Class Reference

Detailed Description

Implements a secure (SSL/TLS) TCP socket.

The CYITCPSecureSocket class provides methods to send and receive data over a TCP/IP connection in a secure manner by using the SSL protocol. Modern SSL v3.1 has been renamed to TLS v1.1 and the version used is determined by the server but CYITCPSecureSocket is restricted to TLS v1.1 and higher.

#include <network/YiTCPSecureSocket.h>

Inheritance diagram for CYITCPSecureSocket:

Public Member Functions

virtual ~CYITCPSecureSocket ()
 
virtual IYISocket::Result Connect (std::chrono::milliseconds timeout=std::chrono::minutes(1)) override
 
virtual IYISocket::Result Disconnect () override
 
virtual bool IsConnected () const override
 
virtual IYISocket::Result Send (const char *pBuffer, size_t length, std::chrono::milliseconds timeout=std::chrono::minutes(1)) override
 
virtual IYISocket::Result Send (const char *pBuffer, size_t length, size_t &sent, std::chrono::milliseconds timeout=std::chrono::minutes(1)) override
 
virtual IYISocket::Result Receive (char *pBuffer, size_t length, size_t &received, std::chrono::milliseconds timeout=std::chrono::minutes(1)) override
 
virtual uint64_t GetTotalBytesSent () const override
 
virtual uint64_t GetTotalBytesReceived () const override
 
- Public Member Functions inherited from IYISocket
virtual ~IYISocket ()
 

Static Public Member Functions

static std::unique_ptr< CYITCPSecureSocketCreate (const CYIString &host, uint16_t port)
 

Protected Member Functions

 CYITCPSecureSocket (const CYIString &host, uint16_t port)
 

Additional Inherited Members

- Public Types inherited from IYISocket
enum  Result {
  Result::Success = 0,
  Result::Error,
  Result::NotConnected,
  Result::Close,
  Result::TimedOut
}
 Possible return values from socket operations. More...
 

Constructor & Destructor Documentation

virtual CYITCPSecureSocket::~CYITCPSecureSocket ( )
virtual
CYITCPSecureSocket::CYITCPSecureSocket ( const CYIString host,
uint16_t  port 
)
protected

Member Function Documentation

virtual IYISocket::Result CYITCPSecureSocket::Connect ( std::chrono::milliseconds  timeout = std::chrono::minutes(1))
overridevirtual

Initiates a connection based on the socket's address and configuration. Returns Result to indicate socket operation result. timeout is the length of time in milliseconds that the socket will wait for a connection before aborting the Connect() operation. The default timeout is set to 1 minute.

Note
Setting timeout to NO_TIMEOUT will cause the operation to never timeout.

Implements IYISocket.

static std::unique_ptr<CYITCPSecureSocket> CYITCPSecureSocket::Create ( const CYIString host,
uint16_t  port 
)
static

Factory method to create a secure socket based on the host and port passed in. Returns the created CYITCPSecureSocket.

virtual IYISocket::Result CYITCPSecureSocket::Disconnect ( )
overridevirtual

Closes the connection on the socket. Returns Result to indicate socket operation result.

Implements IYISocket.

virtual uint64_t CYITCPSecureSocket::GetTotalBytesReceived ( ) const
overridevirtual

Returns the total number of bytes received during the lifetime of the socket.

Implements IYISocket.

virtual uint64_t CYITCPSecureSocket::GetTotalBytesSent ( ) const
overridevirtual

Returns the total number of bytes sent during the lifetime of the socket.

Implements IYISocket.

virtual bool CYITCPSecureSocket::IsConnected ( ) const
overridevirtual

Returns true if the socket is connected.

Implements IYISocket.

virtual IYISocket::Result CYITCPSecureSocket::Receive ( char *  pBuffer,
size_t  length,
size_t received,
std::chrono::milliseconds  timeout = std::chrono::minutes(1) 
)
overridevirtual

Receives a character buffer, pBuffer from a socket, passing in the length,length, of the buffer. received is an output parameter representing the number of bytes successfully received. Returns Result to indicate socket operation result. timeout is the length of time in milliseconds that the socket will wait for until reporting an error. The default timeout is set to 1 minute.

Note
Setting timeout to NO_TIMEOUT will cause the operation to never timeout.

Implements IYISocket.

virtual IYISocket::Result CYITCPSecureSocket::Send ( const char *  pBuffer,
size_t  bufferSize,
std::chrono::milliseconds  timeout = std::chrono::minutes(1) 
)
overridevirtual

Sends the entire contents of the specified buffer to the socket. timeout is the length of time in milliseconds that the socket will wait for until reporting an error. The default timeout is set to 1 minute.

Note
Setting timeout to NO_TIMEOUT will cause the operation to never timeout.

Returns Result to indicate socket operation result.

Implements IYISocket.

virtual IYISocket::Result CYITCPSecureSocket::Send ( const char *  pBuffer,
size_t  bufferSize,
size_t sent,
std::chrono::milliseconds  timeout = std::chrono::minutes(1) 
)
overridevirtual

Tries to send the specified buffer to the socket. sent is an output parameter representing the number of bytes that were successfully sent (the operation may be partial and so the remainder of the buffer needs to be sent separately in such a case). timeout is the length of time in milliseconds that the socket will wait for until reporting an error. The default timeout is set to 1 minute.

Note
Setting timeout to NO_TIMEOUT will cause the operation to never timeout. Returns Result to indicate socket operation result.

Implements IYISocket.


The documentation for this class was generated from the following file: