corrected address construction

This commit is contained in:
nbillard 2023-02-07 13:09:05 +01:00
parent 2d36f2b1fd
commit 6a7eb53b00

View file

@ -163,16 +163,17 @@ int main (int argc, char **argv)
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = DEFAULTPORT;
printf("%s\n", hostname);
hp = gethostbyname(hostname);
if (hp == NULL) {
printf("hosname not found\n");
/* herror("Error: "); */
exit(1);
}
printf("hostname found\n");
/* printf("%s\n", hostname); */
/* hp = gethostbyname(hostname); */
/* if (hp == NULL) { */
/* printf("hosname not found\n"); */
/* /\* herror("Error: "); *\/ */
/* exit(1); */
/* } */
/* printf("hostname found\n"); */
memcpy(&addr.sin_addr.s_addr, hp->h_addr, hp->h_length);
/* memcpy(&addr.sin_addr.s_addr, hp->h_addr, hp->h_length); */
addr.sin_addr.s_addr = INADDR_ANY;
printf("address built\n");
if (bind(sock, (struct sockaddr*) &addr, (sizeof(addr))) < 0 ) {