see the following code:
accept(sockfd, (struct sockaddr*)&cliaddr, &slen); cout << inet_ntop(AF_INET, cliaddr.sin_addr, ipv4addr, 100); my client connects from localhost. i get an absurd address in the output. this is not my ip address. everytime i run the code i get a different ip address. when i ping that ip address i don't get any response.
what is the reason.
i am running suse linux on a virtual machine in windows vista.
Update:
bzero(&cliaddr, sizeof(cliaddr)); int connfd = accept(sockfd, (struct sockaddr*)&cliaddr, &slen); if (sem_wait(&mutex) < 0) err_sys("sem_init error"); char ipv4addr[100]; cout << inet_ntop(AF_INET, &cliaddr.sin_addr, ipv4addr, 100) << endl; //const char* p = inet_ntop(AF_INET, &cliaddr.sin_addr, ipv4addr, 100); //cout << p << endl; //cout << (void*)p << " " << (void*)ipv4addr << endl; this returns address as 0.0.0.0
if i uncomment the lines, i get the correct address in all the lines, 127.0.0.1