icinga2/base/socket.h

47 lines
741 B
C
Raw Normal View History

#ifndef SOCKET_H
#define SOCKET_H
2012-03-28 13:24:49 +02:00
namespace icinga {
class Socket : public Object
{
private:
2012-03-28 13:24:49 +02:00
SOCKET m_FD;
protected:
2012-03-28 13:24:49 +02:00
Socket(void);
void Close(bool from_dtor);
public:
typedef shared_ptr<Socket> RefType;
typedef weak_ptr<Socket> WeakRefType;
static list<Socket::WeakRefType> Sockets;
~Socket(void);
void SetFD(SOCKET fd);
SOCKET GetFD(void) const;
static void CloseAllSockets(void);
event<EventArgs::RefType> OnReadable;
event<EventArgs::RefType> OnWritable;
event<EventArgs::RefType> OnException;
event<EventArgs::RefType> OnClosed;
virtual bool WantsToRead(void) const;
virtual bool WantsToWrite(void) const;
virtual void Start(void);
virtual void Stop(void);
void Close(void);
};
}
#endif /* SOCKET_H */