#include "soc.h"

#define DATA "The sea is calm, the tide is full..."

/* Here I send a data gram to a receiver whose name I get from 
the command line arguments.  The format of the command line :
prgname pathname */

main ( int argc, char *argv[])
{
 int sock;
 struct sockaddr_un name;
 char buf[1024];
 int i;

 /* create socket on which to send */
 sock = socket(AF_UNIX, SOCK_DGRAM, 0);
 if (sock < 0) {
   perror("opeing datagram socket");
   exit(1);
 }

 /* construct name of socket to send to */
 name.sun_family = AF_UNIX;
 strcpy(name.sun_path, argv[1]);

 printf(" This is NODE 0, sending message to socket NODE 1\n");
 
/* send message */
 if (sendto (sock, DATA, sizeof(DATA), 0, (struct sockaddr *)&name,
                                  sizeof(struct sockaddr_un)) < 0){
   perror("sending datagram message"); exit(1); }


 close(sock);
 exit(0);
}



