6 #include <sys/socket.h>
7 #include <netinet/in.h>
11 #define MESSAGE "Yow!!! Are we having fun yet?!?"
12 #define SERVERHOST "mescaline.gnu.org"
15 write_to_server (int filedes
)
19 nbytes
= write (filedes
, MESSAGE
, strlen (MESSAGE
) + 1);
31 extern void init_sockaddr (struct sockaddr_in
*name
,
35 struct sockaddr_in servername
;
37 /* Create the socket. */
38 sock
= socket (PF_INET
, SOCK_STREAM
, 0);
41 perror ("socket (client)");
45 /* Connect to the server. */
46 init_sockaddr (&servername
, SERVERHOST
, PORT
);
47 if (0 > connect (sock
,
48 (struct sockaddr
*) &servername
,
51 perror ("connect (client)");
55 /* Send data to the server. */
56 write_to_server (sock
);