BSD 4_3 development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Wed, 29 Aug 1984 05:54:09 +0000 (21:54 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Wed, 29 Aug 1984 05:54:09 +0000 (21:54 -0800)
Work on file usr/guest/karels/tests/sockopt.c

Synthesized-from: CSRG/cd1/4.3

usr/guest/karels/tests/sockopt.c [new file with mode: 0644]

diff --git a/usr/guest/karels/tests/sockopt.c b/usr/guest/karels/tests/sockopt.c
new file mode 100644 (file)
index 0000000..d0d654e
--- /dev/null
@@ -0,0 +1,35 @@
+#include <sys/param.h>
+#include <sys/socket.h>
+
+main()
+{
+       int s, optlen, ret;
+       int buf[12];
+
+       s = socket(AF_INET, SOCK_DGRAM, 0);
+       optlen = sizeof(buf);
+       bzero(buf, sizeof(buf));
+       if ((ret = getsockopt(s, SOL_SOCKET, SO_DEBUG, buf, &optlen)) < 0)
+               perror("getsockopt SO_DEBUG");
+       else
+               printf("ret = %d, debug = %x (len = %d)\n", ret, buf[0], optlen);
+
+       if (setsockopt(s, SOL_SOCKET, SO_DEBUG, 0, 0) < 0)
+               perror("setsockopt");
+       optlen = sizeof(buf);
+       bzero(buf, sizeof(buf));
+       if ((ret = getsockopt(s, SOL_SOCKET, SO_DEBUG, buf, &optlen)) < 0)
+               perror("getsockopt SO_DEBUG");
+       else
+               printf("ret = %d, debug = %x (len = %d)\n", ret, buf[0], optlen);
+
+       if (setsockopt(s, SOL_SOCKET, SO_DEBUG, buf, sizeof(buf[0])) < 0)
+               perror("setsockopt2");
+
+       optlen = sizeof(buf);
+       bzero(buf, sizeof(buf));
+       if ((ret = getsockopt(s, SOL_SOCKET, SO_DEBUG, buf, &optlen)) < 0)
+               perror("getsockopt SO_DEBUG");
+       else
+               printf("ret = %d, debug = %x (len = %d)\n", ret, buf[0], optlen);
+}