AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
agxNet::Socket Class Reference

#include <Socket.h>

+ Inheritance diagram for agxNet::Socket:

Classes

struct  SystemIndependentSocketHandle
 

Public Member Functions

const IPAddress & adr () const
 
void close ()
 Closes the socket disconnecting it if necessary.
 
bool isBlocking () const
 
bool isReady () const
 Tells whether there is some activity on the socket or not.
 
bool isValid () const
 Tells whether the socket is opened or not.
 
bool readyToReceive () const
 
bool readyToSend () const
 
void select (agx::UInt32 timeoutMillis=0)
 
void setBlocking (bool flag)
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referenced & operator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 

Static Public Member Functions

static int getLastError ()
 Returns the last reported error from a system call.
 
- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

 Socket (const IPAddress &adr=IPAddress())
 
virtual ~Socket ()
 Destructor.
 
Socket & operator= (const Socket &s)
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Protected Attributes

IPAddress m_adr
 
bool m_blocking
 
bool m_readyToReceive
 
bool m_readyToSend
 
SystemIndependentSocketHandle m_socket
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Additional Inherited Members

- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 

Detailed Description

Definition at line 244 of file Socket.h.

Constructor & Destructor Documentation

◆ ~Socket()

virtual agxNet::Socket::~Socket ( )
inlineprotectedvirtual

Destructor.

Definition at line 316 of file Socket.h.

◆ Socket()

agxNet::Socket::Socket ( const IPAddress &  adr = IPAddress())
protected

Member Function Documentation

◆ adr()

const IPAddress & agxNet::Socket::adr ( ) const
inline

Definition at line 294 of file Socket.h.

◆ close()

void agxNet::Socket::close ( )

Closes the socket disconnecting it if necessary.

◆ getLastError()

static int agxNet::Socket::getLastError ( )
static

Returns the last reported error from a system call.

Should be called immediately after a socket/connect call has failed. Typically:

retval = ::select(int(handle + 1), &readMask, &writeMask, nullptr, &tv);
if (retval == M_SOCKET_ERROR)
   int errorNo = Socket::getLastError();

◆ isBlocking()

bool agxNet::Socket::isBlocking ( ) const
inline

Definition at line 267 of file Socket.h.

◆ isReady()

bool agxNet::Socket::isReady ( ) const
inline

Tells whether there is some activity on the socket or not.

See SocketSet class description for more info on how to use this method properly.

Returns
  • true if there is some data to read on the socket or if the remote socket has disconnected. The latter case can be detected by checking if subsequent Recv() method returns 0.
  • false if there is no any activity on the socket.

Definition at line 277 of file Socket.h.

◆ isValid()

bool agxNet::Socket::isValid ( ) const

Tells whether the socket is opened or not.

TODO: write some detailed description.

Returns
Returns true if the socket is opened or false otherwise.

◆ operator=()

Socket & agxNet::Socket::operator= ( const Socket &  s)
protected

◆ readyToReceive()

bool agxNet::Socket::readyToReceive ( ) const
inline

Definition at line 284 of file Socket.h.

◆ readyToSend()

bool agxNet::Socket::readyToSend ( ) const
inline

Definition at line 289 of file Socket.h.

◆ select()

void agxNet::Socket::select ( agx::UInt32  timeoutMillis = 0)

◆ setBlocking()

void agxNet::Socket::setBlocking ( bool  flag)

Member Data Documentation

◆ m_adr

IPAddress agxNet::Socket::m_adr
protected

Definition at line 329 of file Socket.h.

◆ m_blocking

bool agxNet::Socket::m_blocking
protected

Definition at line 328 of file Socket.h.

◆ m_readyToReceive

bool agxNet::Socket::m_readyToReceive
protected

Definition at line 326 of file Socket.h.

◆ m_readyToSend

bool agxNet::Socket::m_readyToSend
protected

Definition at line 327 of file Socket.h.

◆ m_socket

SystemIndependentSocketHandle agxNet::Socket::m_socket
protected

Definition at line 331 of file Socket.h.


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