1 #include "SessionListener.h"
3 namespace remote
{ namespace mcs
{
5 SessionListener::SessionListener(unsigned int port
)
6 : FileDescriptor(openServerSocket(server
, port
, 5, 5)), sessions()
8 log("Listening for client connections on port %u.\n",port
);
11 SessionListener::~SessionListener()
13 sessionmapbyfd_t::iterator cI
;
15 for (cI
= sessions
.begin(); cI
!= sessions
.end(); cI
++)
16 cI
->second
->destroy(true);
19 void SessionListener::handleEvent(short events
)
21 // for now, just try to accept a client connection
22 struct sockaddr_in client
;
24 if (events
& POLLIN
|| events
& POLLPRI
) {
25 int clientsock
= nextClient(fd
, client
);
27 if (clientsock
>= 0) {
28 log("Accepting new client connection\n");
29 new Session(clientsock
, sessions
);