Re: Why the client can't receive the response from server?



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:
SOCKET hSocket = socket(AF_INET, SOCK_STREAM, 0);
SOCKADDR_IN addrConnect;
addrConnect.sin_family = AF_INET;
addrConnect.sin_port = htons(m_uPort); //set port
addrConnect.sin_addr.s_addr = uAddr; //set address

connect(hSocket , (LPSOCKADDR)&addrConnect, sizeof(addrConnect));

//...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(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.











.



Relevant Pages

  • Re: What doesnt lend itself to OO?
    ... >> proxy and instructs the server to constuct the real object. ... rather than client code. ... If 'clock' is instantiated in the server, ... > for the server interface at the OOA level. ...
    (comp.object)
  • This is going straight to the pool room
    ... or not the client has privilege to do what they're trying to do, ... The server environment is this: ... 3GL User action Routines that Tier3 will execute on your behalf during the ... Routine Name: USER_INIT ...
    (comp.os.vms)
  • [Full-Disclosure] R: Full-Disclosure Digest, Vol 3, Issue 42
    ... Full-Disclosure Digest, Vol 3, Issue 42 ... SD Server 4.0.70 Directory Traversal Bug ... Arkeia Network Backup Client Remote Access ...
    (Full-Disclosure)
  • Re: What doesnt lend itself to OO?
    ... > rather than client code. ... no way to do that without also touching the object with clock semantics ... will not encapsulate both clock semantics and network semantics. ... The server can do whatever it wants ...
    (comp.object)
  • RE: Fax monitor incoming + outgoing calls?
    ... problem between the client computer and the SBS server. ... Client is using the internal IP address of the SBS server as the ... To the folder redirection GPO issue: ...
    (microsoft.public.windows.server.sbs)

Quantcast