Dali 3D User Interface Engine
List of all members | Public Member Functions | Private Member Functions | Private Attributes
Dali::Internal::Adaptor::Socket Class Reference

Concrete implementation of a socket under Linux. More...

#include <socket-impl.h>

Inheritance diagram for Dali::Internal::Adaptor::Socket:
Inheritance graph
[legend]
Collaboration diagram for Dali::Internal::Adaptor::Socket:
Collaboration graph
[legend]

Public Member Functions

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

Private Member Functions

bool CreateQuitPipe ()
 Helper to create the quit pipe. More...
 
void DeleteQuitPipe ()
 Helper to delete the quit pipe. More...
 

Private Attributes

int mSocketFileDescriptor
 file descriptor More...
 
int mQuitPipe [2]
 Pipe to inform Select to quit. More...
 
bool mBound:1
 whether the socket is bound More...
 
bool mListening:1
 whether the socket is being listen to More...
 
bool mQuitPipeCreated:1
 whether the quit pipe has been created More...
 
bool mBlocked:1
 whether the socket is blocked waiting for a connection More...
 

Additional Inherited Members

- Public Types inherited from Dali::Internal::Adaptor::SocketInterface
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...
 
- Protected Member Functions inherited from Dali::Internal::Adaptor::SocketInterface
 SocketInterface ()
 Constructor. More...
 
virtual ~SocketInterface ()
 virtual destructor More...
 

Detailed Description

Concrete implementation of a socket under Linux.

Provides automatic closing of socket on destruction.

Definition at line 37 of file socket-impl.h.

Constructor & Destructor Documentation

Dali::Internal::Adaptor::Socket::Socket ( Protocol  protocol,
int  fileDescriptor = -1 
)

Constructor.

Parameters
protocolnetwork protocol
fileDescriptoroption file descriptor if the socket is already open

Definition at line 43 of file socket-impl.cpp.

References DALI_LOG_ERROR, mBound, mSocketFileDescriptor, and Dali::Internal::Adaptor::SocketInterface::UDP.

Referenced by Accept().

Here is the caller graph for this function:

Dali::Internal::Adaptor::Socket::~Socket ( )
virtual

Virtual destructor.

Definition at line 74 of file socket-impl.cpp.

References CloseSocket(), and SocketIsOpen().

Here is the call graph for this function:

Member Function Documentation

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

Wait for connection request and make connection.

Returns
new client socket

Implements Dali::Internal::Adaptor::SocketInterface.

Definition at line 159 of file socket-impl.cpp.

References DALI_LOG_ERROR, mListening, mSocketFileDescriptor, Socket(), and Dali::Internal::Adaptor::SocketInterface::TCP.

Here is the call graph for this function:

bool Dali::Internal::Adaptor::Socket::Bind ( uint16_t  port)
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

Implements Dali::Internal::Adaptor::SocketInterface.

Definition at line 109 of file socket-impl.cpp.

References DALI_LOG_ERROR, mBound, mSocketFileDescriptor, and SocketIsOpen().

Here is the call graph for this function:

bool Dali::Internal::Adaptor::Socket::CloseSocket ( )
virtual

CloseSocket.

Returns
true on success, false on failure

Implements Dali::Internal::Adaptor::SocketInterface.

Definition at line 87 of file socket-impl.cpp.

References DALI_LOG_ERROR, mBound, mListening, mSocketFileDescriptor, and SocketIsOpen().

Referenced by ~Socket().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Dali::Internal::Adaptor::Socket::CreateQuitPipe ( )
private

Helper to create the quit pipe.

Definition at line 184 of file socket-impl.cpp.

References DALI_LOG_ERROR, mQuitPipe, and mQuitPipeCreated.

Referenced by Select().

Here is the caller graph for this function:

void Dali::Internal::Adaptor::Socket::DeleteQuitPipe ( )
private

Helper to delete the quit pipe.

Definition at line 200 of file socket-impl.cpp.

References mQuitPipe, and mQuitPipeCreated.

void Dali::Internal::Adaptor::Socket::ExitSelect ( )
virtual

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

Implements Dali::Internal::Adaptor::SocketInterface.

Definition at line 251 of file socket-impl.cpp.

References DALI_LOG_ERROR, mQuitPipe, and mQuitPipeCreated.

bool Dali::Internal::Adaptor::Socket::Listen ( int  blacklog)
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

Implements Dali::Internal::Adaptor::SocketInterface.

Definition at line 139 of file socket-impl.cpp.

References DALI_LOG_ERROR, mBound, mListening, and mSocketFileDescriptor.

bool Dali::Internal::Adaptor::Socket::Read ( void *  buffer,
unsigned int  bufferSizeInBytes,
unsigned int &  bytesRead 
)
virtual

Implements Dali::Internal::Adaptor::SocketInterface.

Definition at line 308 of file socket-impl.cpp.

References DALI_LOG_ERROR, mSocketFileDescriptor, and SocketIsOpen().

Here is the call graph for this function:

bool Dali::Internal::Adaptor::Socket::ReuseAddress ( bool  reUse)
virtual

Whether the SO_REUSEADDR is enabled or not.

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

Implements Dali::Internal::Adaptor::SocketInterface.

Definition at line 266 of file socket-impl.cpp.

References DALI_LOG_ERROR, mBound, mSocketFileDescriptor, and SocketIsOpen().

Here is the call graph for this function:

SocketInterface::SelectReturn Dali::Internal::Adaptor::Socket::Select ( )
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

Implements Dali::Internal::Adaptor::SocketInterface.

Definition at line 209 of file socket-impl.cpp.

References CreateQuitPipe(), DALI_LOG_ERROR, Dali::Internal::Adaptor::SocketInterface::DATA_AVAILABLE, Dali::Internal::Adaptor::SocketInterface::ERROR, mQuitPipe, mSocketFileDescriptor, and Dali::Internal::Adaptor::SocketInterface::QUIT.

Here is the call graph for this function:

bool Dali::Internal::Adaptor::Socket::SetBufferSize ( SocketInterface::BufferType  type,
unsigned int  bufferSizeInBytes 
)
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

Implements Dali::Internal::Adaptor::SocketInterface.

Definition at line 286 of file socket-impl.cpp.

References DALI_LOG_ERROR, mBound, mSocketFileDescriptor, Dali::Internal::Adaptor::SocketInterface::SEND_BUFFER, and SocketIsOpen().

Here is the call graph for this function:

bool Dali::Internal::Adaptor::Socket::SocketIsOpen ( ) const
virtual

Implements Dali::Internal::Adaptor::SocketInterface.

Definition at line 82 of file socket-impl.cpp.

References mSocketFileDescriptor.

Referenced by Bind(), CloseSocket(), Read(), ReuseAddress(), SetBufferSize(), Write(), and ~Socket().

Here is the caller graph for this function:

bool Dali::Internal::Adaptor::Socket::Write ( const void *  buffer,
unsigned int  bufferLength 
)
virtual

Member Data Documentation

bool Dali::Internal::Adaptor::Socket::mBlocked
private

whether the socket is blocked waiting for a connection

Definition at line 127 of file socket-impl.h.

bool Dali::Internal::Adaptor::Socket::mBound
private

whether the socket is bound

Definition at line 124 of file socket-impl.h.

Referenced by Bind(), CloseSocket(), Listen(), ReuseAddress(), SetBufferSize(), and Socket().

bool Dali::Internal::Adaptor::Socket::mListening
private

whether the socket is being listen to

Definition at line 125 of file socket-impl.h.

Referenced by Accept(), CloseSocket(), and Listen().

int Dali::Internal::Adaptor::Socket::mQuitPipe[2]
private

Pipe to inform Select to quit.

Definition at line 123 of file socket-impl.h.

Referenced by CreateQuitPipe(), DeleteQuitPipe(), ExitSelect(), and Select().

bool Dali::Internal::Adaptor::Socket::mQuitPipeCreated
private

whether the quit pipe has been created

Definition at line 126 of file socket-impl.h.

Referenced by CreateQuitPipe(), DeleteQuitPipe(), and ExitSelect().

int Dali::Internal::Adaptor::Socket::mSocketFileDescriptor
private

file descriptor

Definition at line 122 of file socket-impl.h.

Referenced by Accept(), Bind(), CloseSocket(), Listen(), Read(), ReuseAddress(), Select(), SetBufferSize(), Socket(), SocketIsOpen(), and Write().


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