Rewrite _dl_runtime_resolve to use nacljmp instead of ret
[glibc/nacl-glibc.git] / manual / examples / isockad.c
blob9c21149a854c8cd964efa7ea0b2be192c1a3a305
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <sys/socket.h>
4 #include <netinet/in.h>
5 #include <netdb.h>
7 void
8 init_sockaddr (struct sockaddr_in *name,
9 const char *hostname,
10 uint16_t port)
12 struct hostent *hostinfo;
14 name->sin_family = AF_INET;
15 name->sin_port = htons (port);
16 hostinfo = gethostbyname (hostname);
17 if (hostinfo == NULL)
19 fprintf (stderr, "Unknown host %s.\n", hostname);
20 exit (EXIT_FAILURE);
22 name->sin_addr = *(struct in_addr *) hostinfo->h_addr;