[cs631apue] Logging Remote IP address
Jan Schaumann
jschauma at stevens.edu
Wed Nov 16 12:01:48 EST 2016
bzhang41 <bzhang41 at stevens.edu> wrote:
> I have a question about the remote IP address.
> I am trying to get the client's IP address, after I call the `accept`
>
> client_sock2 = accept(server_sock2,(struct sockaddr *)&client_name,
>
> &clientname_len);
>
> But the IP address I got from the client_name.sin_addr is always
> 0.0.0.0.
You need to use getpeername(3) to get the information about the client
side.
-Jan
More information about the cs631apue
mailing list