Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "c.h"
00016
00017 #include <fcntl.h>
00018
00019
00020 bool
00021 pg_set_noblock(pgsocket sock)
00022 {
00023 #if !defined(WIN32)
00024 return (fcntl(sock, F_SETFL, O_NONBLOCK) != -1);
00025 #else
00026 unsigned long ioctlsocket_ret = 1;
00027
00028
00029 return (ioctlsocket(sock, FIONBIO, &ioctlsocket_ret) == 0);
00030 #endif
00031 }
00032
00033
00034 bool
00035 pg_set_block(pgsocket sock)
00036 {
00037 #if !defined(WIN32)
00038 int flags;
00039
00040 flags = fcntl(sock, F_GETFL);
00041 if (flags < 0 || fcntl(sock, F_SETFL, (long) (flags & ~O_NONBLOCK)))
00042 return false;
00043 return true;
00044 #else
00045 unsigned long ioctlsocket_ret = 0;
00046
00047
00048 return (ioctlsocket(sock, FIONBIO, &ioctlsocket_ret) == 0);
00049 #endif
00050 }