This server code is expected to receive new data in 'recvBuffer'. But donno why it doesnt clear the data received in previous iteration. It sort of mixes current data and previous data...
Nope ...even after removing recvBuffer = NULL its not working... I did that coz delete[] frees up memory but pointer keeps on pointing to the same location hence becomes dangling pointer...
You're not using the return value from OdlServer::ReceiveData(), which tells you exactly how many bytes were written to the destination array. Without that information, you can't know where the current transmission ends. And since new is likely returning the same pointer over and over again, the bytes from the last transmission are still there, confusing you into thinking some incorrect code has overwritten the buffer.
PS: What, is it now hip to not use frakking [code] tags?
why not use a static char array buffer to avoid new/free frequently?
No, don't do that! It makes your function non-reentrant, non-threadsafe, and hogs a fixed block of memory that could be otherwise used by something else.
why are you doing both the thing
delete[] recvBuffer;
recvBuffer = NULL;