//获取用户信息
CString CMySock::GetMemberInfo(char requestUrl[],char Data[])
{
char RequestData[1024];
strcpy(RequestData,Data);
LPHOSTENT lphost= gethostbyname(requestUrl);
sockaddr_in server;
server.sin_family = AF_INET;
//server.sin_addr.s_addr = ((LPIN_ADDR)lphost->h_addr)->s_addr;
server.sin_addr.s_addr = inet_addr(requestUrl);
server.sin_port = htons(this->m_Port);
if (connect(this->m_ManagerSock, (struct sockaddr *)&server, sizeof(struct sockaddr)) == SOCKET_ERROR){
MessageBox(NULL,_T("连接失败,请重试!"),_T("错误"),MB_OK|MB_ICONINFORMATION);
closesocket(this->m_ManagerSock);
return NULL;
}
int retval= send(this->m_ManagerSock,RequestData,sizeof(RequestData)-1,0);
char buffer[1024]={0};
CString strResult;
//char resultBuffer[1024] = "";
while( SOCKET_ERROR!= retval && retval>0)
{
if (SOCKET_Select(this->m_ManagerSock))
{
ZeroMemory(buffer,sizeof(buffer));
retval = recv(this->m_ManagerSock ,(char*)buffer,sizeof(buffer),0);
strResult += buffer;
}
}
return strResult;
}
在另外一个函数中进行调用:
char sz[] =