9#include <daq/dataflow/SocketManager.h>
11#include <netinet/in.h>
16#include <sys/socket.h>
22SocketManager::SocketManager(
int sock)
26 FD_SET(sock, &m_allset);
31SocketManager::~SocketManager()
35int SocketManager::examine()
38 memcpy(&m_rset, &m_allset,
sizeof(m_rset));
39 memcpy(&m_wset, &m_allset,
sizeof(m_wset));
46 int rc = select(m_maxfd + 1, &m_rset, NULL, NULL, NULL);
65 if (FD_ISSET(m_sock, &m_rset)) {
69 struct sockaddr_in isa;
70 socklen_t i =
sizeof(isa);
71 getsockname(m_sock, (
struct sockaddr*)&isa, &i);
72 if ((t =::accept(m_sock, (
struct sockaddr*)&isa, &i)) < 0) {
77 printf(
"New socket registered t=%d, list size = %lu\n", t, m_fd.size());
79 if (t > m_maxfd) m_maxfd = t;
87vector<int>& SocketManager::connected_socket_list()
92bool SocketManager::connected(
int fd,
bool wreq)
95 if (FD_ISSET(fd, &m_rset))
100 if (FD_ISSET(fd, &m_wset))
107bool SocketManager::remove(
int fd)
109 FD_CLR(fd, &m_allset);
110 shutdown(fd, SHUT_RDWR);
112 vector<int>::iterator pos = find(m_fd.begin(), m_fd.end(), fd);
113 if (pos != m_fd.end()) {
Abstract base class for different kinds of events.