* Copyright (c) 1986 The Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
"@(#) Copyright (c) 1986 The Regents of the University of California.\n\
static char sccsid
[] = "@(#)ustreamwrite.c 6.4 (Berkeley) 3/7/89";
#define DATA "Half a league, half a league . . ."
* This program connects to the socket named in the command line and sends a
* one line message to that socket. The form of the command line is
struct sockaddr_un server
;
sock
= socket(AF_UNIX
, SOCK_STREAM
, 0);
perror("opening stream socket");
/* Connect socket using name specified by command line. */
server
.sun_family
= AF_UNIX
;
strcpy(server
.sun_path
, argv
[1]);
if (connect(sock
, &server
, sizeof(struct sockaddr_un
)) < 0) {
perror("connecting stream socket");
if (write(sock
, DATA
, sizeof(DATA
)) < 0)
perror("writing on stream socket");