corrected address construction
This commit is contained in:
parent
2d36f2b1fd
commit
6a7eb53b00
1 changed files with 10 additions and 9 deletions
19
tsock_v0.c
19
tsock_v0.c
|
|
@ -163,16 +163,17 @@ int main (int argc, char **argv)
|
||||||
memset(&addr, 0, sizeof(addr));
|
memset(&addr, 0, sizeof(addr));
|
||||||
addr.sin_family = AF_INET;
|
addr.sin_family = AF_INET;
|
||||||
addr.sin_port = DEFAULTPORT;
|
addr.sin_port = DEFAULTPORT;
|
||||||
printf("%s\n", hostname);
|
/* printf("%s\n", hostname); */
|
||||||
hp = gethostbyname(hostname);
|
/* hp = gethostbyname(hostname); */
|
||||||
if (hp == NULL) {
|
/* if (hp == NULL) { */
|
||||||
printf("hosname not found\n");
|
/* printf("hosname not found\n"); */
|
||||||
/* herror("Error: "); */
|
/* /\* herror("Error: "); *\/ */
|
||||||
exit(1);
|
/* exit(1); */
|
||||||
}
|
/* } */
|
||||||
printf("hostname found\n");
|
/* 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");
|
printf("address built\n");
|
||||||
if (bind(sock, (struct sockaddr*) &addr, (sizeof(addr))) < 0 ) {
|
if (bind(sock, (struct sockaddr*) &addr, (sizeof(addr))) < 0 ) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue