ok doing a chat client, and i am having a problem with the receive part of my client. what i receive from the server won't display on the screen, and i can't work out why
Code:
for (;;)
{
cin >> sendBuffer;
if (strcmp(sendBuffer, "quit") == 0)
{
stopClient(mysocket);
system("cls");
}
if (strcmp(sendBuffer, "help") == 0)
{
cout<<"Commands List"<<endl;
cout<<"quit = exit to main screen"<<endl;
}
else
{
send(mysocket, sendBuffer, strlen(sendBuffer), 0);
while (nbytesrecv == SOCKET_ERROR)
{
nbytesrecv = recv(mysocket, receiveBuffer, 256, 0);
if (nbytesrecv == 0 || nbytesrecv == WSAECONNRESET)
{
cout << "Connection Closed" << endl;
break;
}
if (nbytesrecv < 0)
return;
cout << " " << receiveBuffer << endl;
}
}
}