This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Populate metaconfig branch.
[metaconfig.git] / U / compline / sockopt.U
1 ?RCS: $Id: sockopt.U,v 3.0.1.1 1995/07/25 14:16:14 ram Exp $
2 ?RCS:
3 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
4 ?RCS: 
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
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
8 ?RCS: that same Artistic Licence; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 3.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 +ldflags 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 ?LINT:set d_keepalive
32 : see if setsockopt with SO_KEEPALIVE works as advertised
33 echo " "
34 case "$d_oldsock" in
35 "$undef")
36         if $contains SO_KEEPALIVE `./findhdr sys/socket.h` \
37                 /dev/null >/dev/null 2>&1
38         then
39                 echo "OK, let's see if SO_KEEPALIVE works as advertised..." >&4
40                 $cat > socket.c <<EOP
41 #include <sys/types.h>
42 #include <sys/socket.h>
43 #include <netinet/in.h>
44 #include <netdb.h>
45
46 int main()
47 {
48         int s = socket(AF_INET, SOCK_STREAM, 0);
49         if (s == -1)
50                 exit(1);
51         if (-1 == setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, 0, 0))
52                 exit(2);
53         exit(0);
54 }
55 EOP
56                 if $cc $ccflags $sockethdr $ldflags -o socket socket.c $libs \
57                         $socketlib >/dev/null 2>&1; then
58                         ./socket >/dev/null 2>&1
59                         case $? in
60                         0) echo "Yes, it does!"
61                                 val="$define";;
62                         1) $cat <<EOM
63 (Something went wrong -- Assuming SO_KEEPALIVE is broken)
64 EOM
65                                 val="$undef";;
66                         2) echo "No, it doesn't.  Don't trust your manuals!!"
67                                 val="$undef";;
68                         esac
69                 else
70                         cat <<EOM
71 (I can't compile the test program -- Assuming SO_KEEPALIVE is broken)
72 EOM
73                         val="$undef"
74                 fi
75         else
76                 echo "Strange!! You have BSD 4.2 sockets but no SO_KEEPALIVE option."
77                 val="$undef"
78         fi;;
79 *) cat <<EOM
80 As you have an old socket interface, you can't have heard of SO_KEEPALIVE.
81 EOM
82         val="$undef";;
83 esac
84 set d_keepalive
85 eval $setvar
86 $rm -f socket socket.c
87