127700Smckusick .\" Copyright (c) 1986 Regents of the University of California. 227700Smckusick .\" All rights reserved. The Berkeley software License Agreement 327700Smckusick .\" specifies the terms and conditions for redistribution. 427700Smckusick .\" 5*27884Skarels .\" @(#)ustreamwrite.c 6.3 (Berkeley) 05/08/86 627700Smckusick .\" 727700Smckusick #include <sys/types.h> 827700Smckusick #include <sys/socket.h> 927700Smckusick #include <sys/un.h> 1027700Smckusick #include <stdio.h> 1127700Smckusick 1227700Smckusick #define DATA "Half a league, half a league . . ." 1327700Smckusick 1427700Smckusick /* 1527700Smckusick * This program connects to the socket named in the command line and sends a 1627700Smckusick * one line message to that socket. The form of the command line is 1727700Smckusick * ustreamwrite pathname 1827700Smckusick */ 1927700Smckusick main(argc, argv) 20*27884Skarels int argc; 21*27884Skarels char *argv[]; 2227700Smckusick { 23*27884Skarels int sock; 2427700Smckusick struct sockaddr_un server; 25*27884Skarels char buf[1024]; 2627700Smckusick 2727700Smckusick /* Create socket */ 2827700Smckusick sock = socket(AF_UNIX, SOCK_STREAM, 0); 2927700Smckusick if (sock < 0) { 3027700Smckusick perror("opening stream socket"); 31*27884Skarels exit(1); 3227700Smckusick } 3327700Smckusick /* Connect socket using name specified by command line. */ 3427700Smckusick server.sun_family = AF_UNIX; 3527700Smckusick strcpy(server.sun_path, argv[1]); 3627700Smckusick 3727700Smckusick if (connect(sock, &server, sizeof(struct sockaddr_un)) < 0) { 3827700Smckusick close(sock); 3927700Smckusick perror("connecting stream socket"); 40*27884Skarels exit(1); 4127700Smckusick } 4227700Smckusick if (write(sock, DATA, sizeof(DATA)) < 0) 4327700Smckusick perror("writing on stream socket"); 4427700Smckusick } 45