.\" Copyright (c
) 1986 Regents of the University of California
.
.\" All rights reserved
. The Berkeley software License Agreement
.\" specifies the terms
and conditions
for redistribution
.
.\" @
(#)udgramsend.c 6.2 (Berkeley) 5/8/86
#define DATA "The sea is calm tonight, the tide is full . . ."
* Here I send a datagram to a receiver whose name I get from the command
* line arguments. The form of the command line is udgramsend pathname
/* Create socket on which to send. */
sock
= socket(AF_UNIX
, SOCK_DGRAM
, 0);
perror("opening datagram socket");
/* Construct name of socket to send to. */
name
.sun_family
= AF_UNIX
;
strcpy(name
.sun_path
, argv
[1]);
if (sendto(sock
, DATA
, sizeof(DATA
), 0,
&name
, sizeof(struct sockaddr_un
)) < 0) {
perror("sending datagram message");