Added support for blocking on multiple sockets simultaneously

This commit is contained in:
Fred Nicolson
2016-12-09 23:52:16 +00:00
parent 9cbe2aa8e8
commit b581418f2e
8 changed files with 171 additions and 33 deletions
+32
View File
@@ -0,0 +1,32 @@
//
// Created by fred on 09/12/16.
//
#ifndef FRNETLIB_SOCKETSELECTOR_H
#define FRNETLIB_SOCKETSELECTOR_H
#include "NetworkEncoding.h"
#include "Socket.h"
#include "TcpListener.h"
namespace fr
{
class SocketSelector
{
public:
SocketSelector() noexcept;
bool wait();
void add(const Socket &socket);
bool is_ready(const Socket &socket);
void remove(const Socket &socket);
private:
fd_set listen_set;
fd_set listen_read;
int32_t max_descriptor;
};
}
#endif //FRNETLIB_SOCKETSELECTOR_H