2 $Id: socket.c,v 1.1 2009-10-26 12:35:56 franklahm Exp $
3 Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
18 #endif /* HAVE_CONFIG_H */
23 int setnonblock(int fd, int cmd)
28 if ((fdflags = ofdflags = fcntl(fd, F_GETFL, 0)) == -1)
32 fdflags |= O_NONBLOCK;
34 fdflags &= ~O_NONBLOCK;
36 if (fdflags != ofdflags)
37 if (fcntl(fd, F_SETFL, fdflags) == -1)