1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
?RCS: $Id: sockopt.U 1 2006-08-24 12:32:52Z rmanfredi $
?RCS:
?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
?RCS:
?RCS: You may redistribute only under the terms of the Artistic Licence,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
?RCS: that same Artistic Licence; a copy of which may be found at the root
?RCS: of the source tree for dist 4.0.
?RCS:
?RCS: $Log: sockopt.U,v $
?RCS: Revision 3.0.1.1 1995/07/25 14:16:14 ram
?RCS: patch56: obsoleted KEEPALIVE in favor of CAN_KEEPALIVE for consistency
?RCS:
?RCS: Revision 3.0 1993/08/18 12:09:48 ram
?RCS: Baseline for dist 3.0 netwide release.
?RCS:
?MAKE:d_keepalive: cat rm contains +cc +ccflags socketlib sockethdr \
d_oldsock libs Oldconfig Setvar Findhdr
?MAKE: -pick add $@ %<
?S:d_keepalive:
?S: This symbol conditionally defines CAN_KEEPALIVE which indicates to the C
?S: program that setsockopt SO_KEEPALIVE will work properly.
?S:.
?C:CAN_KEEPALIVE (KEEPALIVE):
?C: This symbol if defined indicates to the C program that the SO_KEEPALIVE
?C: option of setsockopt() will work as advertised in the manual.
?C:.
?H:#$d_keepalive CAN_KEEPALIVE /**/
?H:.
?F:!socket
?LINT:set d_keepalive
: see if setsockopt with SO_KEEPALIVE works as advertised
echo " "
case "$d_oldsock" in
"$undef")
if $contains SO_KEEPALIVE `./findhdr sys/socket.h` \
/dev/null >/dev/null 2>&1
then
echo "OK, let's see if SO_KEEPALIVE works as advertised..." >&4
$cat > socket.c <<EOP
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
int main()
{
int s = socket(AF_INET, SOCK_STREAM, 0);
if (s == -1)
exit(1);
if (-1 == setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, 0, 0))
exit(2);
exit(0);
}
EOP
if $cc $ccflags $sockethdr -o socket socket.c $libs \
$socketlib >/dev/null 2>&1; then
./socket >/dev/null 2>&1
case $? in
0) echo "Yes, it does!"
val="$define";;
1) $cat <<EOM
(Something went wrong -- Assuming SO_KEEPALIVE is broken)
EOM
val="$undef";;
2) echo "No, it doesn't. Don't trust your manuals!!"
val="$undef";;
esac
else
cat <<EOM
(I can't compile the test program -- Assuming SO_KEEPALIVE is broken)
EOM
val="$undef"
fi
else
echo "Strange!! You have BSD 4.2 sockets but no SO_KEEPALIVE option."
val="$undef"
fi;;
*) cat <<EOM
As you have an old socket interface, you can't have heard of SO_KEEPALIVE.
EOM
val="$undef";;
esac
set d_keepalive
eval $setvar
$rm -f socket socket.c
|