Strange client's address returned throug accept(..) function.

Posted by Negai on Stack Overflow See other posts from Stack Overflow or by Negai
Published on 2010-03-21T13:27:23Z Indexed on 2010/03/21 13:31 UTC
Read the original article Hit count: 271

Hi everyone,

I'm a socket programming newbie. Here's a snippet:

struct sockaddr_storage client_addr;

...

client_addr_size = sizeof(client_addr);
client_socket = accept( server_socket,
    (struct sockaddr *)&client_addr, &client_addr_size );

...

result = inet_ntop( AF_INET,
    &((struct sockaddr_in *)&client_addr)->sin_addr,
    client_addr_str, sizeof(client_addr_str) );

Whenever the client connects the address I get is 0.0.0.0 regardless from the host. Can anybody explain, what I'm doing wrong?

Thanks.

© Stack Overflow or respective owner

Related posts about linux

Related posts about sockets