1 /* Example from glibc manual (16.9.6). */
2 /* { dg-require-effective-target sockets } */
4 /* Needed on some targets until we have exception-handling working (PR 111475). */
5 /* { dg-additional-options "-fno-exceptions" } */
7 /* { dg-skip-if "" { hppa*-*-hpux* powerpc*-*-aix* } } */
14 #include <sys/types.h>
15 #include <sys/socket.h>
16 #include <netinet/in.h>
20 #define MESSAGE "Yow!!! Are we having fun yet?!?"
21 #define SERVERHOST "www.gnu.org"
24 write_to_server (int filedes
)
28 nbytes
= write (filedes
, MESSAGE
, strlen (MESSAGE
) + 1);
40 extern void init_sockaddr (struct sockaddr_in
*name
,
44 struct sockaddr_in servername
;
46 /* Create the socket. */
47 sock
= socket (PF_INET
, SOCK_STREAM
, 0);
50 perror ("socket (client)");
54 /* Connect to the server. */
55 init_sockaddr (&servername
, SERVERHOST
, PORT
);
56 if (0 > connect (sock
,
57 (struct sockaddr
*) &servername
,
60 perror ("connect (client)");
64 /* Send data to the server. */
65 write_to_server (sock
);