Why the client can't receive the response from server?
- From: "bucher" <bucher@xxxxxxxx>
- Date: Mon, 20 Nov 2006 18:37:12 +0800
Hi,
I want to send some data to the server. The server sent the response data
successfully, but the client can't receive data.
The code like below:
server side:
SOCKET hClient = accept(sktServer, 0, 0);
//...receive data
send(hClient, buffer, iLen, 0); //This statement executes successfully
shutdown(hClient, SD_BOTH);
closesocket(hClient);
client side:
//...send data
timeval timeout;
memset(&timeout, 0, sizeof(timeval));
timeout.tv_sec = 2;
timeout.tv_usec = 0;
fd_set fd_read_set;
FD_ZERO(&fd_read_set);
FD_SET(hSocket, &fd_read_set); //hSocket was used to send data to server
int errorRet = select(0, NULL, &fd_read_set, NULL, &timeout);
if(errorRet== SOCKET_ERROR){
//error
}else if(errorRet == 0){
//timeout
}else{
int bytesRead;
while ( (bytesRead = recv(m_hSocket, buffer, READ_BUFFER_SIZE, 0)) != 0)
{
if(bytesRead == SOCKET_ERROR){
TRACE("The error code in CClientSocket::WaitForReply is %d\n",
WSAGetLastError());
return FALSE;
}
//...
}
The errorRet is often set to 0 or the WSAGetLastError get the error code
10053. Can someone help me?
Thanks in advanced.
.
- Follow-Ups:
- Re: Why the client can't receive the response from server?
- From: bucher
- Re: Why the client can't receive the response from server?
- From: Arkady Frenkel
- Re: Why the client can't receive the response from server?
- Prev by Date: Re: max connections
- Next by Date: Re: max connections
- Previous by thread: max connections
- Next by thread: Re: Why the client can't receive the response from server?
- Index(es):
Relevant Pages
|