Dali 3D User Interface Engine
List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions
Dali::Internal::Adaptor::SocketInterface Class Referenceabstract

Abstract socket interface. More...

#include <socket-interface.h>

Inheritance diagram for Dali::Internal::Adaptor::SocketInterface:
Inheritance graph
[legend]

Public Types

enum  Protocol { TCP, UDP }
 Protocol type. More...
 
enum  SelectReturn { DATA_AVAILABLE, QUIT, ERROR }
 Select return values. More...
 
enum  BufferType { SEND_BUFFER, RECIEVE_BUFFER }
 Socket buffer type. More...
 

Public Member Functions

virtual bool SocketIsOpen () const =0
 check is a socket is open More...
 
virtual bool CloseSocket ()=0
 CloseSocket. More...
 
virtual bool Bind (uint16_t port)=0
 Socket bind, associate a local address with a socket ( normally uses AF_INET + INADDR_ANY) More...
 
virtual bool Listen (int blacklog)=0
 Indicate a willingness to accept incoming connection requests. More...
 
virtual SocketInterfaceAccept () const =0
 Wait for connection request and make connection. More...
 
virtual SelectReturn Select ()=0
 Waits for an event to occur (data available / error) Returns when. More...
 
virtual void ExitSelect ()=0
 To be called from a separate thread to break out of select. More...
 
virtual bool Read (void *buffer, unsigned int bufferSizeInBytes, unsigned int &bytesRead)=0
 Read data from the socket. More...
 
virtual bool Write (const void *buffer, unsigned int bufferSizeInBytes)=0
 Send data to the socket. More...
 
virtual bool ReuseAddress (bool reUse)=0
 Whether the SO_REUSEADDR is enabled or not. More...
 
virtual bool SetBufferSize (BufferType type, unsigned int size)=0
 Set the send and recieve buffer sizes ( SO_SNDBUF, SO_RCVBUF ) More...
 

Protected Member Functions

 SocketInterface ()
 Constructor. More...
 
virtual ~SocketInterface ()
 virtual destructor More...
 

Private Member Functions

 SocketInterface (const SocketInterface &)
 
SocketInterfaceoperator= (const SocketInterface &)
 

Detailed Description

Abstract socket interface.

The typical usage is:

socket->ReuseAddress( true );
socket->Bind( port );
socket->Listen();
ret = socket->Select(); // call socket->ExitSelect to break from select from another thread
if ( ret == DATA_AVAILABLE )
{
socket->Read( ...);
}
socket->Close();

Definition at line 51 of file socket-interface.h.

Member Enumeration Documentation

Socket buffer type.

Enumerator
SEND_BUFFER 

(SO_SNDBUF) Send buffer size

RECIEVE_BUFFER 

(SO_RCVBUF) Size of buffer allocated to hold data arriving to the socket

Definition at line 153 of file socket-interface.h.

Protocol type.

Enumerator
TCP 

Reliable, connection oriented.

UDP 

Connection less, no guarantees of packet delivery, ordering.

Definition at line 58 of file socket-interface.h.

Select return values.

Enumerator
DATA_AVAILABLE 

Data is available to read.

QUIT 

ExitSelect() has been called on the socket.

ERROR 

Socket error.

Definition at line 99 of file socket-interface.h.

Constructor & Destructor Documentation

Dali::Internal::Adaptor::SocketInterface::SocketInterface ( )
inlineprotected

Constructor.

Definition at line 172 of file socket-interface.h.

virtual Dali::Internal::Adaptor::SocketInterface::~SocketInterface ( )
inlineprotectedvirtual

virtual destructor

Definition at line 179 of file socket-interface.h.

Dali::Internal::Adaptor::SocketInterface::SocketInterface ( const SocketInterface )
private

Member Function Documentation

virtual SocketInterface* Dali::Internal::Adaptor::SocketInterface::Accept ( ) const
pure virtual

Wait for connection request and make connection.

Returns
new client socket

Implemented in Dali::Internal::Adaptor::Socket.

Referenced by Dali::Internal::Adaptor::NetworkPerformanceServer::ConnectionListener().

Here is the caller graph for this function:

virtual bool Dali::Internal::Adaptor::SocketInterface::Bind ( uint16_t  port)
pure virtual

Socket bind, associate a local address with a socket ( normally uses AF_INET + INADDR_ANY)

Parameters
[in]portnetwork port
Returns
true on success, false on failure

Implemented in Dali::Internal::Adaptor::Socket.

Referenced by Dali::Internal::Adaptor::NetworkPerformanceServer::Start().

Here is the caller graph for this function:

virtual bool Dali::Internal::Adaptor::SocketInterface::CloseSocket ( )
pure virtual

CloseSocket.

Returns
true on success, false on failure

Implemented in Dali::Internal::Adaptor::Socket.

Referenced by Dali::Internal::Adaptor::NetworkPerformanceServer::Stop(), and Dali::Internal::Adaptor::NetworkPerformanceClient::~NetworkPerformanceClient().

Here is the caller graph for this function:

virtual void Dali::Internal::Adaptor::SocketInterface::ExitSelect ( )
pure virtual

To be called from a separate thread to break out of select.

Implemented in Dali::Internal::Adaptor::Socket.

Referenced by Dali::Internal::Adaptor::NetworkPerformanceClient::ExitSelect(), and Dali::Internal::Adaptor::NetworkPerformanceServer::Stop().

Here is the caller graph for this function:

virtual bool Dali::Internal::Adaptor::SocketInterface::Listen ( int  blacklog)
pure virtual

Indicate a willingness to accept incoming connection requests.

Parameters
[in]backlogmaximum length of the queue of pending connections.
Returns
true on success, false on failure

Implemented in Dali::Internal::Adaptor::Socket.

Referenced by Dali::Internal::Adaptor::NetworkPerformanceServer::Start().

Here is the caller graph for this function:

SocketInterface& Dali::Internal::Adaptor::SocketInterface::operator= ( const SocketInterface )
private
virtual bool Dali::Internal::Adaptor::SocketInterface::Read ( void *  buffer,
unsigned int  bufferSizeInBytes,
unsigned int &  bytesRead 
)
pure virtual

Read data from the socket.

Parameters
[out]bufferdata
[in]bufferSizeInBytesbuffer size in bytes
[out]bytesReadnumber of bytes read
Returns
true on success, false on failure

Implemented in Dali::Internal::Adaptor::Socket.

virtual bool Dali::Internal::Adaptor::SocketInterface::ReuseAddress ( bool  reUse)
pure virtual

Whether the SO_REUSEADDR is enabled or not.

Parameters
[in]reuseflag.
Returns
true on success, false on failure

Implemented in Dali::Internal::Adaptor::Socket.

Referenced by Dali::Internal::Adaptor::NetworkPerformanceServer::Start().

Here is the caller graph for this function:

virtual SelectReturn Dali::Internal::Adaptor::SocketInterface::Select ( )
pure virtual

Waits for an event to occur (data available / error) Returns when.

  • data has been sent to the socket
  • client has closed the connection ( Read will return 0 bytes)
  • ExitSelect has been called (returns QUIT)
  • There is an error (returns ERROR)
    Returns
    DATA_AVAILABLE if data is available

Implemented in Dali::Internal::Adaptor::Socket.

Referenced by Dali::Internal::Adaptor::NetworkPerformanceServer::ClientThread(), and Dali::Internal::Adaptor::NetworkPerformanceServer::ConnectionListener().

Here is the caller graph for this function:

virtual bool Dali::Internal::Adaptor::SocketInterface::SetBufferSize ( BufferType  type,
unsigned int  size 
)
pure virtual

Set the send and recieve buffer sizes ( SO_SNDBUF, SO_RCVBUF )

Parameters
[in]typebuffer type
[in]sizebuffer size
Returns
true on success, false on failure

Implemented in Dali::Internal::Adaptor::Socket.

virtual bool Dali::Internal::Adaptor::SocketInterface::SocketIsOpen ( ) const
pure virtual

check is a socket is open

Returns
true if the socket is currently open

Implemented in Dali::Internal::Adaptor::Socket.

Referenced by Dali::Internal::Adaptor::NetworkPerformanceClient::~NetworkPerformanceClient().

Here is the caller graph for this function:

virtual bool Dali::Internal::Adaptor::SocketInterface::Write ( const void *  buffer,
unsigned int  bufferSizeInBytes 
)
pure virtual

Send data to the socket.

Parameters
[in]bufferdata to write
[in]bufferSizeInBytesbuffer size in write
Returns
true on success, false on failure

Implemented in Dali::Internal::Adaptor::Socket.

Referenced by Dali::Internal::Adaptor::NetworkPerformanceClient::TransmitMarker(), and Dali::Internal::Adaptor::NetworkPerformanceClient::WriteSocket().

Here is the caller graph for this function:


The documentation for this class was generated from the following file:
Dali Docs Home
Read more about Dali