diff --git a/libretroshare/src/pqi/pqifdbin.cc b/libretroshare/src/pqi/pqifdbin.cc index a15b58689..d5634793d 100644 --- a/libretroshare/src/pqi/pqifdbin.cc +++ b/libretroshare/src/pqi/pqifdbin.cc @@ -37,15 +37,21 @@ RsFdBinInterface::RsFdBinInterface(int file_descriptor) void RsFdBinInterface::setSocket(int s) { - if(mIsActive != 0) - { - RsErr() << "Changing socket to active FsBioInterface! Canceling all pending R/W data." ; - close(); - } + if(mIsActive != 0) + { + RsErr() << "Changing socket to active FsBioInterface! Canceling all pending R/W data." ; + close(); + } +#ifndef WINDOWS_SYS int flags = fcntl(s,F_GETFL); if(!(flags & O_NONBLOCK)) throw std::runtime_error("Trying to use a blocking file descriptor in RsFdBinInterface. This is not going to work!"); +#else + // On windows, there is no way to determine whether a socket is blobking or not, so we set it to non blocking whatsoever. + unsigned long int on = 1; + ret = ioctlsocket(fd[STDOUT_FILENO], FIONBIO, &on); +#endif mCLintConnt = s; mIsActive = (s!=0); diff --git a/libretroshare/src/pqi/rstcpsocket.cc b/libretroshare/src/pqi/rstcpsocket.cc index 13a93d70a..8f77a993b 100644 --- a/libretroshare/src/pqi/rstcpsocket.cc +++ b/libretroshare/src/pqi/rstcpsocket.cc @@ -61,8 +61,13 @@ bool RsTcpSocket::connect() } mState = CONNECTED; +#ifndef WINDOWS_SYS int flags = fcntl(CreateSocket,F_GETFL); fcntl(CreateSocket, F_SETFL, flags | O_NONBLOCK); +#else + unsigned long int on = 1; + ret = ioctlsocket(fd, FIONBIO, &on); +#endif setSocket(CreateSocket); diff --git a/libretroshare/src/tor/TorManager.cpp b/libretroshare/src/tor/TorManager.cpp index e12b81d1b..9d84910ce 100644 --- a/libretroshare/src/tor/TorManager.cpp +++ b/libretroshare/src/tor/TorManager.cpp @@ -175,8 +175,13 @@ static bool test_listening_port(const std::string& /*address*/,uint16_t port) close(sockfd); return false; } +#ifndef WINDOWS_SYS int flags = fcntl(sockfd, F_GETFL); fcntl(sockfd, F_SETFL, flags | O_NONBLOCK); +#else + unsigned long int on = 1; + ret = ioctlsocket(fd, FIONBIO, &on); +#endif int res = listen(sockfd,5); diff --git a/libretroshare/src/tor/TorProcess.cpp b/libretroshare/src/tor/TorProcess.cpp index c33fbb876..8ae8721db 100644 --- a/libretroshare/src/tor/TorProcess.cpp +++ b/libretroshare/src/tor/TorProcess.cpp @@ -272,9 +272,14 @@ void TorProcess::start() } int flags ; +#ifndef WINDOWS_SYS flags = fcntl(fd[STDOUT_FILENO], F_GETFL); fcntl(fd[STDOUT_FILENO], F_SETFL, flags | O_NONBLOCK); flags = fcntl(fd[STDERR_FILENO], F_GETFL); fcntl(fd[STDERR_FILENO], F_SETFL, flags | O_NONBLOCK); - +#else + unsigned long int on = 1; + ret = ioctlsocket(fd[STDOUT_FILENO], FIONBIO, &on); + ret = ioctlsocket(fd[STDERR_FILENO], FIONBIO, &on); +#endif mStdOutFD = new RsFdBinInterface(fd[STDOUT_FILENO]); mStdErrFD = new RsFdBinInterface(fd[STDERR_FILENO]); }