bool SocketsApi::IsSelfConnect(socket_t sockfd) { sockaddr_in_t localaddr = GetLocalAddr(sockfd); sockaddr_in_t peeraddr = GetPeerAddr(sockfd); return localaddr.sin_port == peeraddr.sin_port && localaddr.sin_addr.s_addr == peeraddr.sin_addr.s_addr; }
BOOL Frame::DosePeerUseBroadcastAddress()const { const uchar* broadcast_addr = g_myconfig.GetBroadcastAddr(); const uchar* peer_addr = GetPeerAddr(); if ( 0 == memcmp(broadcast_addr, peer_addr, 2) ) { return TRUE; } else { return FALSE; } }
const char *GetTcpInfor(int peerfd)//get tcp information { static char infor[100] = ""; //store information SAI Peer = GetPeerAddr(peerfd);//get peerfd addr SAI Local = GetLocalAddr(peerfd);//get local addr snprintf(infor, sizeof infor, "%s:%d -> %s:%d", GetIp(&Local),//get ip GetPort(&Local), GetIp(&Peer),//get port GetPort(&Peer)); return infor; }