how to know destination IP address (in frdmk64 with KSDK 1.1.0 )

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to know destination IP address (in frdmk64 with KSDK 1.1.0 )

Jump to solution
397 Views
sudhakarp
Contributor V

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

Labels (1)
0 Kudos
1 Solution
304 Views
sudhakarp
Contributor V

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

View solution in original post

0 Kudos
1 Reply
305 Views
sudhakarp
Contributor V

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

0 Kudos