50# pragma warning( disable : 4290)
51# pragma warning( disable: 4275 )
84 NetError(
const char* message) :
std::runtime_error(message), m_socket(nullptr) {}
86 NetError(
const char* message,
Socket* socket) :
std::runtime_error(message), m_socket(socket) {}
146 m_host(
agx::UInt32(h1) + (
agx::UInt32(h2)<<8) + (
agx::UInt32(h3)<<16) + (
agx::UInt32(h4)<<24)),
165 return (this->m_host == ip.m_host) && (this->m_port == ip.m_port);
225 SINGLETON_CLASSNAME_METHOD();
232 void deinitSockets();
251#ifndef DOC_DONT_EXTRACT
279 return m_readyToReceive;
286 return m_readyToReceive;
291 return m_readyToSend;
369 this->open(ip, disableNaggle);
379 this->Socket::operator=(s);
418 void disableNaggle();
457 this->Socket::operator=(s);
469 this->open(port, disableNaggle);
491 bool m_disableNaggle;
#define AGX_DECLARE_POINTER_TYPES(type)
#define AGX_DECLARE_VECTOR_TYPES(type)
a structure which holds IP address
const agx::UInt32 & host() const
IPAddress()
Default constructor.
agx::String string() const
IPAddress(agx::UInt32 h, agx::UInt16 p)
Create IP address specifying exact ip address and port number.
const agx::UInt16 & port() const
IPAddress(const agx::String &ip, agx::UInt16 p)
Create IP address specifying ip address as string and port number.
bool operator==(const IPAddress &ip)
compares two IP addresses for equality.
IPAddress(agx::UInt8 h1, agx::UInt8 h2, agx::UInt8 h3, agx::UInt8 h4, agx::UInt16 p)
Create IP address specifying exact ip address as 4 bytes and port number.
static Library * instance()
Get the singleton instance.
virtual void shutdown() override
instance the object, after this, the object cannot be used anymore.
IPAddress getHostByName(const char *hostName, agx::UInt16 port)
Resolve host IP by its name.
NetError(const char *message)
Exception constructor.
NetError(const char *message, Socket *socket)
size_t getMaxSockets() const
Returns maximal number of sockets the system allows.
bool addSocket(Socket *sock)
Add a socket to socket set.
SocketSet()
Creates a socket set of the specified size.
virtual ~SocketSet()
Destroys the socket set.
size_t getNumSockets() const
Returns number of sockets the socket set currently holds.
bool checkSockets(agx::UInt32 timeoutMillis)
Check sockets from socket set for activity.
const SocketRefVector & getSockets() const
bool removeSocket(Socket *sock)
Remove socket from socket set.
void select(agx::UInt32 timeoutMillis=0)
static int getLastError()
Returns the last reported error from a system call.
void close()
Closes the socket disconnecting it if necessary.
bool isValid() const
Tells whether the socket is opened or not.
bool readyToReceive() const
Socket & operator=(const Socket &s)
virtual ~Socket()
Destructor.
SystemIndependentSocketHandle m_socket
const IPAddress & adr() const
void setBlocking(bool flag)
bool isReady() const
Tells whether there is some activity on the socket or not.
Socket(const IPAddress &adr=IPAddress())
TCPServerSocket & operator=(const TCPServerSocket &s)
Assignment operator, works similar to std::auto_ptr::operator=().
TCPServerSocket(const TCPServerSocket &s)
A copy constructor.
TCPSocket * accept()
Accepts one of the pending connections, non-blocking.
TCPServerSocket(agx::UInt16 port, bool disableNaggle=false)
A constructor which automatically calls TCPServerSocket::Open() method.
TCPServerSocket()
Creates an invalid (unopened) TCP server socket.
void open(agx::UInt16 port, bool disableNaggle=false)
Connects the socket or starts listening on it.
void sendBlocking(const agx::UInt8 *data, agx::UInt32 size)
void open(const IPAddress &ip, bool disableNaggle=false)
Connects the socket.
TCPSocket(const IPAddress &ip, bool disableNaggle=false)
A constructor which automatically calls TCPSocket::Open() method.
size_t recv(agx::UInt8 *buf, size_t maxSize)
Receive data from connected socket.
TCPSocket(const TCPSocket &s, const IPAddress &adr=IPAddress())
A copy constructor.
void recvBlocking(agx::UInt8 *buf, agx::UInt32 size)
TCPSocket()
Constructs an invalid TCP socket object.
TCPSocket & operator=(const TCPSocket &s)
Assignment operator, works similar to std::auto_ptr::operator=().
void sendBlocking(const StructuredMessage *message)
agx::UInt32 send(const agx::UInt8 *data, agx::UInt32 size)
Send data to connected socket.
Indicates a timeout between server/client.
TimeoutConnectError(const char *message)
Exception constructor.
virtual ~TimeoutConnectError() noexcept
size_t send(const agx::UInt8 *buf, agx::UInt16 size, IPAddress destinationIP)
void open(agx::UInt16 port)
Open the socket.
agx::UInt32 recv(agx::UInt8 *buf, agx::UInt16 maxSize, IPAddress &out_SenderIP)
Base class providing referencing counted objects.
Base class for Singletons that should have its shutdown called explicitly before exit of the applicat...
Containins classes for sending/reading data over sockets as well as compression functionality.
agx::UInt16 AGXCORE_EXPORT getAvailablePort()
std::ostream & operator<<(std::ostream &stream, const IPAddress &adr)
The agx namespace contains the dynamics/math part of the AGX Dynamics API.