Move stop() call from closeTty() to the only calling site needing it
[remote/remote-mci.git] / mcs / FileDescriptor.h
blobeb27f7f0b1ee569c0934bbd56cf2d7dc999ac31c
1 #ifndef _FILEDESCRIPTOR_H_
2 #define _FILEDESCRIPTOR_H_
4 #ifdef HAVE_CONFIG_H
5 #include "config.h"
6 #endif
8 #include "types.h"
9 #include "database.h"
10 #include <stdlib.h>
11 #include <sys/poll.h>
12 #include <signal.h>
13 #include <sys/time.h>
14 #include <errno.h>
16 namespace remote { namespace mcs {
18 class FileDescriptor;
20 typedef std::map<int,FileDescriptor*> filedescriptorsbyfd_t;
22 /** Base class for handling socket connections through file descriptors.
24 **/
25 class FileDescriptor
27 public:
28 /** Main service loop using poll() system call to receive fd events**/
29 static void serviceLoop();
30 /** Handles an event on a specific file descriptor **/
31 virtual void handleEvent(short events) = 0;
32 /** Clean up and destroy a FileDescriptor object **/
33 virtual void destroy(bool silent=false);
34 protected:
35 void setTimeout(int secs);
36 static void clearTimeout();
37 FileDescriptor(int p_fd);
38 virtual ~FileDescriptor();
39 static void buildPollMap(pollfd* map);
40 static RETSIGTYPE timeoutHandler(int sig);
41 static void ignoreBrokenPipeSignals();
42 static filedescriptorsbyfd_t instances;
43 static int currentFd;
44 int fd;
50 #endif