Hi,
i want to Know Destination IP address of the connected remote system.
i tried with getpeername() API function. but i am not getting IP. after accept API function i tried following method
client_sock = accept(conn_sock, NULL, NULL);
getpeername(conn_sock,&addr,sizeof(&addr));
printf("Remote IP=%u\n\r", ((sockaddr_in*) &addr)->sin_addr.s_addr);
any one give solution for this?
thanks and regards,
sudhakar p
Solved! Go to Solution.
hi,
I got solution for this.
client_sock = accept(conn_sock, NULL, NULL);
instead of this i tried
client_sock= accept(conn_sock, &remote_sin, &remote_addrlen);
printf("\nConnection accepted from %lx, port %d",
remote_sin.sin_addr, remote_sin.sin_port);
regards,
sudhakar p
hi,
I got solution for this.
client_sock = accept(conn_sock, NULL, NULL);
instead of this i tried
client_sock= accept(conn_sock, &remote_sin, &remote_addrlen);
printf("\nConnection accepted from %lx, port %d",
remote_sin.sin_addr, remote_sin.sin_port);
regards,
sudhakar p