Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

FDUtil.cxx

00001 /*
00002  * Copyright (C) 1991-9 Eric M. Hopper <hopper@omnifarious.mn.org>
00003  * 
00004  *     This program is free software; you can redistribute it and/or modify it
00005  *     under the terms of the GNU Lesser General Public License as published
00006  *     by the Free Software Foundation; either version 2 of the License, or
00007  *     (at your option) any later version.
00008  * 
00009  *     This program is distributed in the hope that it will be useful, but
00010  *     WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *     Lesser General Public License for more details.
00013  * 
00014  *     You should have received a copy of the GNU Lesser General Public
00015  *     License along with this program; if not, write to the Free Software
00016  *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00018 
00019 /* $Header: /home/hopper/src/cvs/C++/StrMod/FDUtil.cxx,v 1.3 2001/09/23 22:40:41 hopper Exp $ */
00020 
00021 // For a log, see ./ChangeLog
00022 
00023 // $Revision: 1.3 $
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 };  // End namespace strmod
00069 };  // End namespace strmod

Generated on Wed Jan 29 00:32:43 2003 for libNet by doxygen1.3-rc1