Lines 1-5
Link Here
|
|
|
1 |
#include <fcntl.h> |
2 |
#include <sys/ioctl.h> |
3 |
#include <stdio.h> |
1 |
|
4 |
|
2 |
|
|
|
3 |
#ifdef WIN32 |
5 |
#ifdef WIN32 |
4 |
#include <Winsock2.h> |
6 |
#include <Winsock2.h> |
5 |
typedef SOCKET SOCKET_T; |
7 |
typedef SOCKET SOCKET_T; |
Lines 152-165
Link Here
|
152 |
|
154 |
|
153 |
void Socket::setBlocking(bool doBlock) |
155 |
void Socket::setBlocking(bool doBlock) |
154 |
{ |
156 |
{ |
|
|
157 |
int flags; |
158 |
int r; |
159 |
|
160 |
flags = fcntl (_sock->s, F_GETFL); |
161 |
|
155 |
if( doBlock ) |
162 |
if( doBlock ) |
156 |
{ |
163 |
{ |
157 |
u_long iMode = 0; // blocking |
164 |
u_long iMode = 0; // blocking |
158 |
int r = ioctlsocket(_sock->s, FIONBIO, &iMode); |
165 |
//int r = ioctlsocket(_sock->s, FIONBIO, &iMode); |
|
|
166 |
//int r = fcntl(_sock->s, F_SETFL, &iMode) ; |
167 |
r = fcntl (_sock->s, F_SETFL, flags & ~O_NONBLOCK); |
159 |
} else { |
168 |
} else { |
160 |
//set client to non-blocking mode: (is server is non-blocking, so will the clients be) |
169 |
//set client to non-blocking mode: (is server is non-blocking, so will the clients be) |
161 |
u_long iMode = 1; // non-blocking |
170 |
u_long iMode = 1; // non-blocking |
162 |
int r = ioctlsocket(_sock->s, FIONBIO, &iMode); |
171 |
//int r = ioctlsocket(_sock->s, FIONBIO, &iMode); |
|
|
172 |
//int r = fcntl(_sock->s, F_SETFL, &iMode) ; |
173 |
r = fcntl (_sock->s, F_SETFL, flags | O_NONBLOCK); |
163 |
} |
174 |
} |
164 |
//return r==0; //return True if no error. |
175 |
//return r==0; //return True if no error. |
165 |
} |
176 |
} |