summaryrefslogtreecommitdiff
path: root/mcon/U/sockopt.U
diff options
context:
space:
mode:
authorrmanfredi <rmanfredi@190e5f8e-a817-0410-acf6-e9863daed9af>2006-08-24 12:32:52 +0000
committerrmanfredi <rmanfredi@190e5f8e-a817-0410-acf6-e9863daed9af>2006-08-24 12:32:52 +0000
commit8bfc5756fb68e0b13d7e7c0073ad5b9a4790d1b6 (patch)
treedee05e98bc53766d609ef2a3a07a5672627d812c /mcon/U/sockopt.U
Moving project to sourceforge.
git-svn-id: https://dist.svn.sourceforge.net/svnroot/dist/trunk/dist@1 190e5f8e-a817-0410-acf6-e9863daed9af
Diffstat (limited to 'mcon/U/sockopt.U')
-rw-r--r--mcon/U/sockopt.U88
1 files changed, 88 insertions, 0 deletions
diff --git a/mcon/U/sockopt.U b/mcon/U/sockopt.U
new file mode 100644
index 0000000..1a6fc35
--- /dev/null
+++ b/mcon/U/sockopt.U
@@ -0,0 +1,88 @@
+?RCS: $Id$
+?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
+