From 7f478b3b2f182999133e8e2ac623a9b4571d988b Mon Sep 17 00:00:00 2001 From: Kirk McKusick Date: Wed, 7 May 1986 00:08:59 -0800 Subject: [PATCH] tighten up code to reduce wasted paper SCCS-vsn: share/doc/psd/20.ipctut/dgramread.c 6.2 SCCS-vsn: share/doc/psd/20.ipctut/ustreamread.c 6.2 SCCS-vsn: share/doc/psd/20.ipctut/ustreamwrite.c 6.2 --- usr/src/share/doc/psd/20.ipctut/dgramread.c | 7 ++----- usr/src/share/doc/psd/20.ipctut/ustreamread.c | 12 ++++-------- usr/src/share/doc/psd/20.ipctut/ustreamwrite.c | 3 +-- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/usr/src/share/doc/psd/20.ipctut/dgramread.c b/usr/src/share/doc/psd/20.ipctut/dgramread.c index c822c3f8ef..5a1531b9e9 100644 --- a/usr/src/share/doc/psd/20.ipctut/dgramread.c +++ b/usr/src/share/doc/psd/20.ipctut/dgramread.c @@ -2,7 +2,7 @@ .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" -.\" @(#)dgramread.c 6.1 (Berkeley) %G% +.\" @(#)dgramread.c 6.2 (Berkeley) %G% .\" #include #include @@ -17,13 +17,10 @@ * struct in_addr sin_addr; * char sin_zero[8]; * }; - */ - -/* + * * This program creates a datagram socket, binds a name to it, then reads * from the socket. */ - main() { int sock, length; diff --git a/usr/src/share/doc/psd/20.ipctut/ustreamread.c b/usr/src/share/doc/psd/20.ipctut/ustreamread.c index 2eced7a405..14223f9335 100644 --- a/usr/src/share/doc/psd/20.ipctut/ustreamread.c +++ b/usr/src/share/doc/psd/20.ipctut/ustreamread.c @@ -2,14 +2,13 @@ .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" -.\" @(#)ustreamread.c 6.1 (Berkeley) %G% +.\" @(#)ustreamread.c 6.2 (Berkeley) %G% .\" #include #include #include #include -#define TRUE 1 #define NAME "socket" /* @@ -19,15 +18,13 @@ * connection breaks, or a termination message comes through, the program * accepts a new connection. */ - main() { int sock; struct sockaddr_un server; int msgsock; char buf[1024]; - int rval; - int i; + int rval, i; /* Create socket */ sock = socket(AF_UNIX, SOCK_STREAM, 0); @@ -42,10 +39,9 @@ main() perror("binding stream socket"); } printf("Socket has name %s\en", server.sun_path); - /* Start accepting connections */ listen(sock, 5); - do { + for (;;) { msgsock = accept(sock, 0, 0); do { for (i = 0; i < 1024; i++) @@ -59,7 +55,7 @@ main() }; } while (rval != 0); close(msgsock); - } while (TRUE); + } /* * The following statements are not executed, because they follow an * infinite loop. However, most ordinary programs will not run diff --git a/usr/src/share/doc/psd/20.ipctut/ustreamwrite.c b/usr/src/share/doc/psd/20.ipctut/ustreamwrite.c index e8991d790d..992bdcdac0 100644 --- a/usr/src/share/doc/psd/20.ipctut/ustreamwrite.c +++ b/usr/src/share/doc/psd/20.ipctut/ustreamwrite.c @@ -2,7 +2,7 @@ .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" -.\" @(#)ustreamwrite.c 6.1 (Berkeley) %G% +.\" @(#)ustreamwrite.c 6.2 (Berkeley) %G% .\" #include #include @@ -16,7 +16,6 @@ * one line message to that socket. The form of the command line is * ustreamwrite pathname */ - main(argc, argv) int argc; char *argv[]; -- 2.20.1