|
if(WSAStartup(MAKEWORD(1,1),&wsaData) == 0)
{
SOCKADDR_IN addr;
m_Sock = socket(AF_INET,SOCK_STREAM,0);
if(m_Sock == INVALID_SOCKET)
return false;
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = inet_addr(IP);//IP地址
addr.sin_port = htons(Port);//端口
if(connect(m_Sock,(sockaddr*)&addr,sizeof(addr)) != 0)
{
closesocket(m_Sock);
return false;
}
return true;
}
总是连不上,但找不出是什么问题。
|
|