You.i Engine
IYISocket Class Referenceabstract

Detailed Description

The IYISocket defines the interface to be implemented by any class fulfilling sockets services.

IYISocket is one end of an interprocess communication channel. The user of this interface is responsible for making sure that connections are established before used and the channel is properly closed when finished.

#include <network/YiSocket.h>

Inheritance diagram for IYISocket:

Public Types

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

Public Member Functions

virtual ~IYISocket ()
 
virtual Result Connect (std::chrono::milliseconds timeout=std::chrono::minutes(1))=0
 
virtual Result Disconnect ()=0
 
virtual bool IsConnected () const =0
 
virtual Result Send (const char *pBuffer, size_t bufferSize, std::chrono::milliseconds timeout=std::chrono::minutes(1))=0
 
virtual Result Send (const char *pBuffer, size_t bufferSize, size_t &sent, std::chrono::milliseconds timeout=std::chrono::minutes(1))=0
 
virtual Result Receive (char *pBuffer, size_t length, size_t &received, std::chrono::milliseconds timeout=std::chrono::minutes(1))=0
 
virtual uint64_t GetTotalBytesSent () const =0
 
virtual uint64_t GetTotalBytesReceived () const =0
 

Member Enumeration Documentation

enum IYISocket::Result
strong

Possible return values from socket operations.

Enumerator
Success 
Error 
NotConnected 
Close 
TimedOut 

Constructor & Destructor Documentation

virtual IYISocket::~IYISocket ( )
inlinevirtual

Member Function Documentation

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

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.

Implemented in CYITCPSocket, and CYITCPSecureSocket.

virtual Result IYISocket::Disconnect ( )
pure virtual

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

Implemented in CYITCPSocket, and CYITCPSecureSocket.

virtual uint64_t IYISocket::GetTotalBytesReceived ( ) const
pure virtual

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

Implemented in CYITCPSocket, and CYITCPSecureSocket.

virtual uint64_t IYISocket::GetTotalBytesSent ( ) const
pure virtual

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

Implemented in CYITCPSocket, and CYITCPSecureSocket.

virtual bool IYISocket::IsConnected ( ) const
pure virtual

Returns true if the socket is connected.

Implemented in CYITCPSocket, and CYITCPSecureSocket.

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

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.

Implemented in CYITCPSocket, and CYITCPSecureSocket.

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

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.

Implemented in CYITCPSocket, and CYITCPSecureSocket.

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

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.

Implemented in CYITCPSocket, and CYITCPSecureSocket.


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