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  SOCKET_RESULT {
  YI_SOCKET_SUCCESS,
  YI_SOCKET_ERROR,
  YI_SOCKET_NOT_CONNECTED,
  YI_SOCKET_CLOSE,
  YI_SOCKET_WOULD_BLOCK
}
 Possible return values from socket operations. More...
 

Public Member Functions

virtual ~IYISocket ()
 
virtual bool Connect ()=0
 
virtual bool Disconnect ()=0
 
virtual bool IsConnected () const =0
 
virtual SOCKET_RESULT Send (const char *pBuffer, size_t uLength)=0
 
virtual SOCKET_RESULT Send (const char *pBuffer, size_t uLength, size_t &uSent)=0
 
virtual SOCKET_RESULT Receive (char *pBuffer, size_t uLength, size_t &uReceived)=0
 
virtual uint64_t GetTotalBytesSent () const =0
 
virtual uint64_t GetTotalBytesReceived () const =0
 
virtual void SetConnectionTimeoutMs (uint32_t uTimeoutMs)=0
 
virtual uint32_t GetConnectionTimeoutMs () const =0
 
virtual bool SetSocketBlockingEnabled (bool bBlocking)=0
 

Static Public Member Functions

static bool SOCKET_OPERATION_SUCCEEDED (SOCKET_RESULT eResult)
 

Member Enumeration Documentation

Possible return values from socket operations.

Enumerator
YI_SOCKET_SUCCESS 
YI_SOCKET_ERROR 
YI_SOCKET_NOT_CONNECTED 
YI_SOCKET_CLOSE 
YI_SOCKET_WOULD_BLOCK 

Constructor & Destructor Documentation

virtual IYISocket::~IYISocket ( )
inlinevirtual

Member Function Documentation

virtual bool IYISocket::Connect ( )
pure virtual

Initiates a connection based on the socket's address and configuration. Returns true if successful.

Implemented in CYITCPSocket, and CYITCPSecureSocket.

virtual bool IYISocket::Disconnect ( )
pure virtual

Closes the connection on the socket. Returns true if successful.

Implemented in CYITCPSocket, and CYITCPSecureSocket.

virtual uint32_t IYISocket::GetConnectionTimeoutMs ( ) const
pure virtual

Returns the timeout length in milliseconds.

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 SOCKET_RESULT IYISocket::Receive ( char *  pBuffer,
size_t  uLength,
size_t uReceived 
)
pure virtual

Receives a character buffer, pBuffer from a socket, passing in the length,nLength, of the buffer. nReceived is an output parameter representing the number of bytes successfully received. Returns SOCKET_RESULT to indicate socket operation result.

Implemented in CYITCPSocket, and CYITCPSecureSocket.

virtual SOCKET_RESULT IYISocket::Send ( const char *  pBuffer,
size_t  uLength 
)
pure virtual

Sends a character buffer, pBuffer along with the buffer length, nLength, to the socket. Returns SOCKET_RESULT to indicate socket operation result.

Implemented in CYITCPSocket, and CYITCPSecureSocket.

virtual SOCKET_RESULT IYISocket::Send ( const char *  pBuffer,
size_t  uLength,
size_t uSent 
)
pure virtual

Sends a character buffer, pBuffer along with the buffer length, nLength, to the socket. nSent is an output parameter representing the number of bytes that were successfully sent. Returns SOCKET_RESULT to indicate socket operation result.

Implemented in CYITCPSocket, and CYITCPSecureSocket.

virtual void IYISocket::SetConnectionTimeoutMs ( uint32_t  uTimeoutMs)
pure virtual

Sets the length of time in milliseconds uTimeoutMs that the socket will wait for a connection before aborting the Connect() operation. The default timeout is set to 10 seconds (10000 ms).

Note
Socket timeouts are not supported on Tizen-NaCl. The timeout will not be applied on this platform.

Implemented in CYITCPSocket, and CYITCPSecureSocket.

virtual bool IYISocket::SetSocketBlockingEnabled ( bool  bBlocking)
pure virtual

Utility method modifying the socket's internal flags base on bBlocking. When bBlocking is true, further calls to Send(), Receive(), Connect() and Accept() on the socket will block until a response is received. The default state when a socket is created is blocking. Returns true if the call succeeded.

Implemented in CYITCPSocket, and CYITCPSecureSocket.

static bool IYISocket::SOCKET_OPERATION_SUCCEEDED ( SOCKET_RESULT  eResult)
inlinestatic

Utility method to check return value of socket operation


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