diff --git a/src/exported_connection.cpp b/src/exported_connection.cpp index 2d0fdc920..06af7fcd2 100644 --- a/src/exported_connection.cpp +++ b/src/exported_connection.cpp @@ -1,4 +1,6 @@ +#if !defined(_WIN32) #include +#endif #include "exported_connection.hpp" #include "connection.hpp" @@ -20,8 +22,15 @@ ExportedConnection::ExportedConnection(SharedRefPtr connection) { this->heartbeat_interval_secs_ = connection->heartbeat_interval_secs_; // Socket +#if defined(_WIN32) + uv_fileno(reinterpret_cast(&connection->socket_->tcp_), reinterpret_cast(&this->fd)); + WSAPROTOCOL_INFOW info; + WSADuplicateSocketW(this->fd, GetCurrentProcessId(), &info); + this->fd = WSASocketW(info.iAddressFamily, info.iSocketType, info.iProtocol, &info, 0, WSA_FLAG_OVERLAPPED); +#else uv_fileno(reinterpret_cast(&connection->socket_->tcp_), &this->fd); this->fd = dup(this->fd); +#endif this->handler_ = connection->socket_->handler_.release(); // Set basic handler, to notify Connection about closing, and destroy it. connection->socket_->set_handler(new ConnectionHandler(connection.get())); diff --git a/src/exported_connection.hpp b/src/exported_connection.hpp index d5a76ec55..040187f21 100644 --- a/src/exported_connection.hpp +++ b/src/exported_connection.hpp @@ -40,7 +40,7 @@ class ExportedConnection : public RefCounted { unsigned int heartbeat_interval_secs_; // Socket fields - int fd; + uv_os_sock_t fd; SocketHandlerBase *handler_; bool is_defunct_; size_t max_reusable_write_objects_;