AGX Dynamics 2.40.1.2
Loading...
Searching...
No Matches
agxNet::TCPServerSocket Class Reference

#include <Socket.h>

+ Inheritance diagram for agxNet::TCPServerSocket:

Public Member Functions

 TCPServerSocket ()
 Creates an invalid (unopened) TCP server socket.
 
 TCPServerSocket (agx::UInt16 port, bool disableNaggle=false)
 A constructor which automatically calls TCPServerSocket::Open() method.
 
 TCPServerSocket (const TCPServerSocket &s)
 A copy constructor.
 
TCPSocketaccept ()
 Accepts one of the pending connections, non-blocking.
 
void open (agx::UInt16 port, bool disableNaggle=false)
 Connects the socket or starts listening on it.
 
TCPServerSocketoperator= (const TCPServerSocket &s)
 Assignment operator, works similar to std::auto_ptr::operator=().
 
- Public Member Functions inherited from agxNet::Socket
const IPAddressadr () 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.
 
Referencedoperator= (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.
 

Additional Inherited Members

- Static Public Member Functions inherited from agxNet::Socket
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 inherited from agxNet::Socket
 Socket (const IPAddress &adr=IPAddress())
 
virtual ~Socket ()
 Destructor.
 
Socketoperator= (const Socket &s)
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 
- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandlergetDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 
- Protected Attributes inherited from agxNet::Socket
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
 

Detailed Description

Definition at line 429 of file Socket.h.

Constructor & Destructor Documentation

◆ TCPServerSocket() [1/3]

agxNet::TCPServerSocket::TCPServerSocket ( )
inline

Creates an invalid (unopened) TCP server socket.

Definition at line 434 of file Socket.h.

◆ TCPServerSocket() [2/3]

agxNet::TCPServerSocket::TCPServerSocket ( const TCPServerSocket s)
inline

A copy constructor.

Copy constructor creates a new socket object which refers to the same socket as s. After constructor completes the s becomes invalid. In other words, the behavior of copy constructor is similar to one of std::auto_ptr class from standard C++ library.

Parameters
s- other TCP socket to make a copy from.

Definition at line 444 of file Socket.h.

◆ TCPServerSocket() [3/3]

agxNet::TCPServerSocket::TCPServerSocket ( agx::UInt16  port,
bool  disableNaggle = false 
)
inline

A constructor which automatically calls TCPServerSocket::Open() method.

This constructor creates a socket and calls its TCPServerSocket::Open() method. So, it creates an already opened socket listening on the specified port.

Parameters
port- IP port number to listen on.
disableNaggle- enable/disable Naggle algorithm for all accepted connections.

Definition at line 468 of file Socket.h.

Member Function Documentation

◆ accept()

TCPSocket * agxNet::TCPServerSocket::accept ( )

Accepts one of the pending connections, non-blocking.

Accepts one of the pending connections and returns a TCP socket object which represents either a valid connected socket or an invalid socket object. This function does not block if there is no any pending connections, it just returns invalid socket object in this case. One can periodically check for incoming connections by calling this method.

Returns
A pointer to a TCPSocket object if a valid socket could be initialized. Returns nullptr if there was no any connections pending, so no connection was accepted.

◆ open()

void agxNet::TCPServerSocket::open ( agx::UInt16  port,
bool  disableNaggle = false 
)

Connects the socket or starts listening on it.

This method starts listening on the socket for incoming connections.

Parameters
port- IP port number to listen on.
disableNaggle- enable/disable Naggle algorithm for all accepted connections.

◆ operator=()

TCPServerSocket & agxNet::TCPServerSocket::operator= ( const TCPServerSocket s)
inline

Assignment operator, works similar to std::auto_ptr::operator=().

After this assignment operator completes this socket object refers to the socket the s object referred, s become invalid. It works similar to std::auto_ptr::operator=() from standard C++ library.

Parameters
s- socket to assign from.

Definition at line 456 of file Socket.h.


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