有一種方法可以從客戶端端檢索客戶端的IP地址嗎?什麼是客戶端的客戶端IP
客戶端:
int main(int argc, char *argv[])
{
struct sockaddr_in serv_addr;
portno = atoi(argv[2]); //getting the server port from the terminal
sockfd = socket(AF_INET, SOCK_STREAM, 0);
server = gethostbyname(argv[1]); //getting the server IP from the terminal
bzero((char *) &serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
bcopy((char *)server->h_addr,
(char *)&serv_addr.sin_addr.s_addr,server->h_length);
serv_addr.sin_port = htons(portno);
connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr);
.......
......
}
的感謝!
謝謝:)我得到了它 – user1673206