#include <sys/socket.h>
#endif
#include <iostream>
+#include <msp/io/handle_private.h>
#include <msp/strings/format.h>
#include <msp/time/rawtime_private.h>
#include <msp/time/units.h>
#ifdef WIN32
event = CreateEvent(0, false, false, 0);
+#else
+ *event = handle;
#endif
}
#ifdef WIN32
event = CreateEvent(0, false, false, 0);
+#else
+ *event = handle;
#endif
}
#endif
}
-IO::Handle Socket::get_event_handle()
+const IO::Handle &Socket::get_event_handle()
{
-#ifdef WIN32
return event;
-#else
- return handle;
-#endif
}
#ifndef MSP_NET_SOCKET_H_
#define MSP_NET_SOCKET_H_
-#include <msp/io/base.h>
+#include <msp/io/eventobject.h>
+#include <msp/io/handle.h>
#include "constants.h"
#include "sockaddr.h"
#include "types.h"
namespace Msp {
namespace Net {
-class Socket: public IO::Base
+class Socket: public IO::EventObject
{
protected:
SocketHandle handle;
-#ifdef WIN32
IO::Handle event;
-#endif
bool connected;
SockAddr *local_addr;
SockAddr *peer_addr;
~Socket();
void set_block(bool);
- IO::Handle get_event_handle();
+ const IO::Handle &get_event_handle();
bool is_connected() const { return connected; }
#define MSP_NET_INVALID_SOCKET_HANDLE static_cast<SOCKET>(-1)
#else
-typedef IO::Handle SocketHandle;
+typedef int SocketHandle;
-#define MSP_NET_INVALID_SOCKET_HANDLE MSP_IO_INVALID_HANDLE
+#define MSP_NET_INVALID_SOCKET_HANDLE -1
#endif
} // namespace Net