views:

13

answers:

0

Hey...

I wanted to build my client program in release mode and everything seemed to work fine. The client was able to send data, which have been received by the server. But the client never receives the answer sent by the server.

  1. The server is working correctly
  2. The data size is only up to 200 bytes
  3. sending works...
  4. I am using Visual Studio 2010
  5. I am using UDP

Anyone knows why the client cant receive anything in release mode, but in debug mode?

With regards, Incubbus

code: ( I know it is not the best, but at the moment it is fitting and it is easy to change for future improvements, from my point of view)

int ret, len, fromlen;  //return code / length of the data / sizeof(sockaddr)
 char *buffer;  //will hold the data
 char c;

 //recv length of the message
 fromlen = sizeof(sockaddr);
 ret = recvfrom(m_InSock, &c, 1, 0, addr, (addr != NULL) ? &fromlen : NULL);
 if(ret != 1)
 {
  return Inc::ERECV;
 }

 len = (int)c;

 //allocate space for the message
 buffer = new char[len+1];
 //recv message
 fromlen = sizeof(sockaddr);
 ret = recvfrom(m_InSock, buffer, len, 0, addr, (addr) ? &fromlen : NULL);
 if(ret != len)
 {
  return Inc::ERECV;
 }

 //buffer[len] = '\0';

 //assign buffer to strData
 strData.clear();
 strData.assign(buffer, ret);