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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

ソリューションへジャンプ
412件の閲覧回数
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

ラベル(1)
0 件の賞賛
1 解決策
319件の閲覧回数
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 件の賞賛
1 返信
320件の閲覧回数
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 件の賞賛