1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
BOOL C_Ma_Socket::SendCmd(CString strCmd, CString *strAnswer)
{
BOOL bOut = 0;
int sckError = 0;
int nbrBoucle = 0;
//Envoie de la commande
sckError = this->Send(LPCTSTR(strCmd),strCmd.GetLength()+1, 0);
if(sckError != SOCKET_ERROR)
{
//Création d'un buffer pour lire la réponse
char * pBuf = new char[4096];
memset(pBuf, 0, 4096);
sckError = this->Receive(pBuf, 4096, 0);
if(sckError != SOCKET_ERROR)
{
strAnswer->Format("%s", pBuf);
bOut = 1;
}
//Libération de la mémoire du buffer pour la réponse
delete(pBuf);
}
return bOut;
} |
Partager