I'm writing a remote control program, even thought i havn't got so far yet
The clients sending code:
The servers reciving code:Code://Send to server char buffer[256]; // On the stack ZeroMemory(buffer, 256); strcpy(buffer, "THEDAMNPASSWORD"); nret = send(theSocket, buffer, 256, // Note that this specifies the length of the string; not // the size of the entire buffer 0); // Most often is zero, but see MSDN for other options if (nret == SOCKET_ERROR) { // Get a specific code // Handle accordingly return NETWORK_ERROR; } else { // nret contains the number of bytes sent } // Cleanup: closesocket(theSocket); WSACleanup(); }
Code:char buffer[256]; ZeroMemory(buffer, 256); nret = recv(theClient, buffer, 256, // Complete size of buffer 0); if (nret == SOCKET_ERROR) { // Get a specific code // Handle accordingly return NETWORK_ERROR; } else { if(buffer == "THEDAMNPASSWORD") { cout << "Client sendt right password, YES! : " << buffer; } else { cout << "Nope, wrong: " << buffer << endl; } }
Now, the problem is that it says "Nope, wrong: THEDAMNPASSWORD" even thought it's the right password, what is wrong?



LinkBack URL
About LinkBacks



