5 #include <sys/socket.h>
8 #define SERVER "/tmp/serversocket"
9 #define CLIENT "/tmp/mysocket"
11 #define MESSAGE "Yow!!! Are we having fun yet?!?"
16 extern int make_named_socket (const char *name
);
19 struct sockaddr_un name
;
23 /* Make the socket. */
24 sock
= make_named_socket (CLIENT
);
26 /* Initialize the server socket address. */
27 name
.sun_family
= AF_LOCAL
;
28 strcpy (name
.sun_path
, SERVER
);
29 size
= strlen (name
.sun_path
) + sizeof (name
.sun_family
);
31 /* Send the datagram. */
32 nbytes
= sendto (sock
, MESSAGE
, strlen (MESSAGE
) + 1, 0,
33 (struct sockaddr
*) & name
, size
);
36 perror ("sendto (client)");
40 /* Wait for a reply. */
41 nbytes
= recvfrom (sock
, message
, MAXMSG
, 0, NULL
, 0);
44 perror ("recfrom (client)");
48 /* Print a diagnostic message. */
49 fprintf (stderr
, "Client: got message: %s\n", message
);