summaryrefslogtreecommitdiff
path: root/src/net/tcp.c
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-08-05 15:56:30 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-08-05 15:56:30 +0000
commitaecb6c466c1e7efa0f07809aa18096e7d5559850 (patch)
treefaf97599f2562a3da4e43df3587f16666704ce7e /src/net/tcp.c
parentb5723cbd822b2359850c121ca69e682a607d91bd (diff)
- server/client poziva neblokujuci rezim TCP socketov
git-svn-id: http://opensvn.csie.org/tuxanci_ng@190 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/net/tcp.c')
-rwxr-xr-xsrc/net/tcp.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/net/tcp.c b/src/net/tcp.c
index 1c3f6c0..f6c3dad 100755
--- a/src/net/tcp.c
+++ b/src/net/tcp.c
@@ -18,6 +18,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
+#include <fcntl.h>
#include "tcp.h"
@@ -274,6 +275,33 @@ int disableNagle(sock_tcp_t *p)
return result;
}
+int setTcpSockNonBlock(sock_tcp_t *p)
+{
+ /* Set to nonblocking socket mode */
+#ifndef __WIN32__
+ int oldFlag;
+
+ oldFlag = fcntl (p->sock, F_GETFL, 0);
+
+ if( fcntl(p->sock, F_SETFL, oldFlag | O_NONBLOCK) == -1 )
+ {
+ //printf("error setTcpSockNonBlock\n");
+ return -1;
+ }
+
+ //printf("setTcpSockNonBlock OK\n");
+#else
+ unsigned long arg = 1;
+ // Operation is FIONBIO. Parameter is pointer on non-zero number.
+ if( ioctlsocket(p->sock, FIONBIO, &arg) == SOCKET_ERROR )
+ {
+ WSACleanup();
+ return -1;
+ }
+#endif
+ return 0;
+}
+
int readTcpSocket(sock_tcp_t *p, void *address, int len)
{
assert( p != NULL );