00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifdef __GNUG__
00026 # pragma implementation "FDUtil.h"
00027 #endif
00028
00029 #include "StrMod/FDUtil.h"
00030 #include <cerrno>
00031 #include <fcntl.h>
00032
00033 namespace strmod {
00034 namespace strmod {
00035
00036 bool FDUtil::setNonBlock(int fd, int &myerrno)
00037 {
00038 int temp;
00039
00040 if ((temp = fcntl(fd, F_GETFL, 0)) < 0) {
00041 myerrno = errno;
00042 return(false);
00043 }
00044 temp &= ~O_NDELAY;
00045 if (fcntl(fd, F_SETFL, temp | O_NONBLOCK) < 0) {
00046 myerrno = errno;
00047 return(false);
00048 }
00049 return(true);
00050 }
00051
00052 bool FDUtil::setBlock(int fd, int &myerrno)
00053 {
00054 int temp;
00055
00056 if ((temp = fcntl(fd, F_GETFL, 0)) < 0) {
00057 myerrno = errno;
00058 return(false);
00059 }
00060 temp &= ~(O_NDELAY | O_NONBLOCK);
00061 if (fcntl(fd, F_SETFL, temp) < 0) {
00062 myerrno = errno;
00063 return(false);
00064 }
00065 return(true);
00066 }
00067
00068 };
00069 };