#include <iostream>
#include <afxwin.h>
#include <Winsock2.h>
#pragma comment(lib,"Ws2_32.lib")
int main(){
sockaddr_in addrSock1;
addrSock1.sin_family = AF_INET;
addrSock1.sin_port = htons(5555);
addrSock1.sin_addr.s_addr = inet_addr("127.0.0.1");
sockaddr* addrSock2;
addrSock2 = (sockaddr*)&addrSock1;
u_long uPort1 = htons(5555);
u_long uPort2 = MAKEWORD(addrSock2->sa_data[0],addrSock2->sa_data[1]);
return 0;
}
//注意 addSock2->sa_data[0],addSock2->sa_data[1]及MAKEWORD