Nazara Engine
0.4
A fast, complete, cross-platform API designed for game development
|
Network class allowing an application to wait on multiples sockets for them to become active (readable) More...
Public Member Functions | |
SocketPoller () | |
Constructs an empty SocketPoller object. | |
SocketPoller (SocketPoller &&) noexcept=default | |
~SocketPoller () | |
Destructs the SocketPoller. More... | |
void | Clear () |
Clears the SocketPoller. More... | |
bool | IsReadyToRead (const AbstractSocket &socket) const |
Checks if a specific socket is ready to read data. More... | |
bool | IsReadyToWrite (const AbstractSocket &socket) const |
Checks if a specific socket is ready to write data. More... | |
bool | IsRegistered (const AbstractSocket &socket) const |
Checks if a specific socket is registered in the SocketPoller. More... | |
bool | RegisterSocket (AbstractSocket &socket, SocketPollEventFlags eventFlags) |
Register a socket in the SocketPoller. More... | |
void | UnregisterSocket (AbstractSocket &socket) |
Unregister a socket from the SocketPoller. More... | |
bool | Wait (int msTimeout) |
Wait until any registered socket switches to a ready state. More... | |
SocketPoller & | operator= (SocketPoller &&) noexcept=default |
Network class allowing an application to wait on multiples sockets for them to become active (readable)
Nz::SocketPoller::~SocketPoller | ( | ) |
Destructs the SocketPoller.
void Nz::SocketPoller::Clear | ( | ) |
Clears the SocketPoller.
This function reverts the SocketPoller to the initial state, unregistering every socket from the SocketPoller.
bool Nz::SocketPoller::IsReadyToRead | ( | const AbstractSocket & | socket | ) | const |
Checks if a specific socket is ready to read data.
This function allows you to read the results of the last Wait operation and if a specific socket is ready to read (has incoming data).
A socket in the ready to read state (with the exception of TcpServer) has incoming data and can be read without blocking.
socket | Reference to the socket to check |
bool Nz::SocketPoller::IsReadyToWrite | ( | const AbstractSocket & | socket | ) | const |
Checks if a specific socket is ready to write data.
This function allows you to read the results of the last Wait operation and if a specific socket is ready to write (can be written to without blocking).
socket | Reference to the socket to check |
bool Nz::SocketPoller::IsRegistered | ( | const AbstractSocket & | socket | ) | const |
Checks if a specific socket is registered in the SocketPoller.
A registered socket is part of the SocketPoller and will be checked by the next Wait operations.
socket | Reference to the socket to check |
bool Nz::SocketPoller::RegisterSocket | ( | AbstractSocket & | socket, |
SocketPollEventFlags | eventFlags | ||
) |
Register a socket in the SocketPoller.
A registered socket is part of the SocketPoller and will be checked by the next Wait operations according to the event flags passed when registered.
The SocketPoller keeps a reference to the internal handle of registered socket, which should not be freed while it is registered in the SocketPooler.
It is possible for this function to fail if too many sockets are registered in the SocketPoller, the maximum number of socket handled limit is OS-dependent.
socket | Reference to the socket to register |
eventFlags | Socket events to watch |
void Nz::SocketPoller::UnregisterSocket | ( | AbstractSocket & | socket | ) |
Unregister a socket from the SocketPoller.
After calling UnregisterSocket, the socket is no longer part of the SocketPoller and thus, not taken into account by any further Wait call until registered again.
This function must be called before destroying a socket part of the SocketPoller.
socket | Reference to the socket to unregister |
bool Nz::SocketPoller::Wait | ( | int | msTimeout | ) |
Wait until any registered socket switches to a ready state.
Waits a specific/undetermined amount of time until at least one socket part of the SocketPoller becomes ready. To query the ready state of the registered socket, use the IsReadyToRead or IsReadyToWrite functions.
msTimeout | Maximum time to wait in milliseconds, 0 will returns immediately and -1 will block indefinitely |