Hi,
i am using frdmk64. and using kds2.0 and ksdk1.1.0 example. i want to know connected host(or remote) system ip address.
if any function there? i am listening one port but i dnt know which IP was connected to my device.
how to get IP address of Remote(Host) System.
regards,
sudhakar p
Hi
I think you can get the ip address by getpeername(), Please check the MQX RTOS RTCS User's guide for details
7.2.33 getpeername()
Gets the remote endpoint identifier of a socket.
Synopsis
uint32_t getpeername(
uint32_t socket,
sockaddr * name,
uint16_t * namelen)
Have a nice day,
Daniel
hi,
actually i tried following method is it correct..?
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);
but i am getting ZERO only
OUTPUT
Remote IP=0
give some other idea.
regards,
sudhakar p
Hi daniel,
thanks for your information. 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