#ifndef SOCKET_H #define SOCKET_H namespace icinga { struct I2_BASE_API SocketErrorEventArgs : public EventArgs { typedef shared_ptr Ptr; typedef weak_ptr WeakPtr; int Code; string Message; }; class I2_BASE_API Socket : public Object { private: SOCKET m_FD; int ExceptionEventHandler(EventArgs::Ptr ea); protected: string FormatErrorCode(int errorCode); protected: Socket(void); void Close(bool from_dtor); public: typedef shared_ptr Ptr; typedef weak_ptr WeakPtr; static list Sockets; ~Socket(void); void SetFD(SOCKET fd); SOCKET GetFD(void) const; static void CloseAllSockets(void); Event OnReadable; Event OnWritable; Event OnException; Event OnError; Event 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 */