how to get IP of a client Socket connected
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-12 06:38 PM
I'm writing a program using socket API. when a client Socket connected to my server Socket ,I tried to get its IP address but the result returned 0.0.0.0.
int ConnectFD = accept(socketFD, (struct sockaddr *)&remotehost, (socklen_t *)&sockaddrsize);
if( ConnectFD != -1)
{
struct sockaddr_in *ad;
socklen_t len;
ad = (struct sockaddr_in*)&remotehost; printf("client%sconnected,ID:%d\n",ip4addr_ntoa((structip4_addr*)&ad>sin_addr),ConnectFD);
Labels:
- Labels:
-
Ethernet
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-13 06:26 PM
up
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-13 09:40 PM
up