|
@@ -6,6 +6,8 @@
|
|
#include <netinet/in.h>
|
|
#include <netinet/in.h>
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdlib.h>
|
|
|
|
+#include <unistd.h>
|
|
|
|
+#include <fcntl.h>
|
|
#include <sys/socket.h>
|
|
#include <sys/socket.h>
|
|
|
|
|
|
CSocket::CSocket(Type type, CObject* parent)
|
|
CSocket::CSocket(Type type, CObject* parent)
|
|
@@ -31,6 +33,17 @@ bool CSocket::connect(const String& hostname, int port)
|
|
return connect(host_address, port);
|
|
return connect(host_address, port);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void CSocket::set_blocking(bool blocking)
|
|
|
|
+{
|
|
|
|
+ int flags = fcntl(fd(), F_GETFL, 0);
|
|
|
|
+ ASSERT(flags >= 0);
|
|
|
|
+ if (blocking)
|
|
|
|
+ flags = fcntl(fd(), F_SETFL, flags | O_NONBLOCK);
|
|
|
|
+ else
|
|
|
|
+ flags = fcntl(fd(), F_SETFL, flags & O_NONBLOCK);
|
|
|
|
+ ASSERT(flags >= 0);
|
|
|
|
+}
|
|
|
|
+
|
|
bool CSocket::connect(const CSocketAddress& address, int port)
|
|
bool CSocket::connect(const CSocketAddress& address, int port)
|
|
{
|
|
{
|
|
ASSERT(!is_connected());
|
|
ASSERT(!is_connected());
|