mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-04 19:00:09 +00:00
001426b899
1998-03-30 17:20 Ulrich Drepper <drepper@cygnus.com> * Makerules: Remove duplicate rules to handle stamp.oS. 1998-03-30 Andreas Jaeger <aj@arthur.rhein-neckar.de> * manual/examples/inetsrv.c (main): Change prototype of make_socket following change in mkisock.c. * manual/examples/inetcli.c (SERVERHOST): Use mescaline.gnu.org as example host. (main): Change prototype of init_sockaddr following change in isockadd.c. * manual/examples/mkisock.c (make_socket): Use uint16_t for port. * manual/examples/isockad.c (init_sockaddr): Likewise. * manual/examples/mkfsock.c (make_named_socket): Removed blank lines for clarification. (make_named_socket): Use strncpy instead of strcpy. Reported by Francesco Potorti` <F.Potorti@cnuce.cnr.it>.
24 lines
519 B
C
24 lines
519 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <sys/socket.h>
|
|
#include <netinet/in.h>
|
|
#include <netdb.h>
|
|
|
|
void
|
|
init_sockaddr (struct sockaddr_in *name,
|
|
const char *hostname,
|
|
uint16_t port)
|
|
{
|
|
struct hostent *hostinfo;
|
|
|
|
name->sin_family = AF_INET;
|
|
name->sin_port = htons (port);
|
|
hostinfo = gethostbyname (hostname);
|
|
if (hostinfo == NULL)
|
|
{
|
|
fprintf (stderr, "Unknown host %s.\n", hostname);
|
|
exit (EXIT_FAILURE);
|
|
}
|
|
name->sin_addr = *(struct in_addr *) hostinfo->h_addr;
|
|
}
|