如下资料是关于C++根据SOCKET获取套接字IP、Port等信息的内容。
bool GetAddressBySocket(SOCKET m_socket,SOCKADDR_IN &m_address)
{
memset(&m_address, 0, sizeof(m_address));
int nAddrLen = sizeof(m_address);
{ printf("Get IP address by socket failed!n"); return false; } cout<<"IP: "<<::inet_ntoa(m_address.sin_addr)<<" PORT: "<<ntohs(m_address.sin_port)<<endl; return true;
}