Expand|Select|Wrap|Line Numbers
- while(1){
- int nret = 0;
- nret = recv(m_socket,buffer,100,0);
- if(nret == SOCKET_ERROR) {
- nret = WSAGetLastError();
- //throw error
- }
- buffer[nret-1] = '\0';
- printf("Recv:%s\n",buffer);
- }
- server calls recv for the first time. buffer gets "h????????????", nret = 1. so the buffer is got "" after truncating.
- it continues to call recv, buffer gets "ello????????", nret = 5. the buffer is "ello" then.
I don't know why the recv called 2 times. Please help me! Thank you in advance.
Best regards,
Voicon