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