1 /* Test for nonblocking read and write.
3 Copyright (C) 2011-2012 Free Software Foundation, Inc.
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 3 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.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 /* A data block ought to be larger than the size of the in-kernel buffer.
19 Working values of SOCKET_DATA_BLOCK_SIZE, depending on kernel:
21 Platform SOCKET_DATA_BLOCK_SIZE
23 Linux >= 7350000 (depends on circumstances)
26 MacOS X >= 680000 (depends on circumstances)
28 AIX 7.1 >= 200000 (depends on circumstances)
32 Solaris 7 >= 63000 (depends on circumstances)
36 Solaris 11 2010-11 >= 73729
37 Cygwin 1.5.x >= 66294401 but then write() fails with ENOBUFS
38 Cygwin 1.7.x >= 163838 (depends on circumstances)
39 native Windows >= 66294401
41 #if defined __OpenBSD__
42 # define SOCKET_DATA_BLOCK_SIZE 100000
44 # define SOCKET_DATA_BLOCK_SIZE 1000000
47 /* On Linux, MacOS X, Cygwin 1.5.x, native Windows,
48 sockets have very large buffers in the kernel, so that write() calls
49 succeed before the reader has started reading, even if fd is blocking
50 and the amount of data is larger than 1 MB. */
51 #if defined __linux__ || (defined __APPLE__ && defined __MACH__) || (defined _WIN32 || defined __WIN32__) || defined __CYGWIN__
52 # define SOCKET_HAS_LARGE_BUFFER 1
54 # define SOCKET_HAS_LARGE_BUFFER 0