Inexplicable problem using dev-cpp to compile simple winsock example
Howdy all. I am having some serious trouble using Bloodshed dev-cpp to compile an example winsock server I got from the web and messed around with a little bit. I am not sure what I'm doing wrong but I hope someone here can help. The following is the code which handles incoming data.
Code:
int HandleData(WPARAM wParam, LPARAM lParam)
{
SOCKET sock = (SOCKET)wParam;
WORD event = LOWORD(lParam);
WORD error = HIWORD(lParam);
if (event == FD_CLOSE)
{
closesocket(sock);
}
else if (event == FD_READ)
{
char szBuffer[1024];
char *ret;
ZeroMemory(szBuffer, 1024);
recv(sock, szBuffer, 1024, 0);
MessageBox(Main.hWnd, szBuffer, "Received Data!", MB_OK);
if (strstr(szBuffer, "result")){
SetWindowText(Edit2.hWnd, szBuffer);}
closesocket(sock);
}
return TRUE;
}
If i leave in the "MessageBox(Main.hWnd, szBuffer, "Received Data!", MB_OK);" line then everything works as expected, (Edit2 displays my buffer.) but if I comment out the MessageBox line than Edit2 remains empty even when the buffer contains the magic word.(In this case 'result'). How is this possible, and how can I 'fix' it so that it behaves the way I mean for it to behave? Thank you for wasting your time reading this :)
Oh-Yeah... I am using Bloodshed dev-cpp version 4.9.8.0 if that helps.
<Edit: I fixed my wonky code tags...I dont know what I was thinking before:) >