|
@@ -28,6 +28,10 @@
|
|
|
#include <errno.h>
|
|
|
#include <sys/socket.h>
|
|
|
|
|
|
+#ifndef SOCK_NONBLOCK
|
|
|
+# include <sys/ioctl.h>
|
|
|
+#endif
|
|
|
+
|
|
|
namespace Core {
|
|
|
|
|
|
TCPSocket::TCPSocket(int fd, Object* parent)
|
|
@@ -43,7 +47,13 @@ TCPSocket::TCPSocket(int fd, Object* parent)
|
|
|
TCPSocket::TCPSocket(Object* parent)
|
|
|
: Socket(Socket::Type::TCP, parent)
|
|
|
{
|
|
|
+#ifdef SOCK_NONBLOCK
|
|
|
int fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
|
|
|
+#else
|
|
|
+ int fd = socket(AF_INET, SOCK_STREAM, 0);
|
|
|
+ int option = 1;
|
|
|
+ ioctl(fd, FIONBIO, &option);
|
|
|
+#endif
|
|
|
if (fd < 0) {
|
|
|
set_error(errno);
|
|
|
} else {
|