【VC++】socket小程序获取连接者的IP问题

2025-03-05 12:38:35
推荐回答(2个)
回答1:

size = sizeof(sockaddr);
newfd = accept(sockfd,(struct sockaddr*)&new_add,&size); printf("%s\n",inet_ntoa(new_add.sin_addr));//转换成字符IP

回答2:

inet_ntoa(m_remoteAddr.sin_addr);