Re: Server can receive in a socket, but what it sends isn't received in the client.

From: Arkady Frenkel (arkadyf_at_hotmailxdotx.com)
Date: 07/15/04


Date: Thu, 15 Jul 2004 10:54:15 +0300

Do you really have established connection ?
Check that on both sides 2 sockets have state established in netstat of
dosbox
Arkady

"David" <dabid5@yahoo.es> wrote in message
news:cedc4027.0407140456.2e9d4906@posting.google.com...
> Hi,
> I have used both synchronous and asynchronous sockets and i'm stuck at
> this very moment becouse the socket in the server side that holds the
> connection with the client can't send. The code is very simple
> although i can't see what's wrong with it.
>
> Any idea would be gladly appreciated, thank you very much in advance
> and excuse my bad english.
> David.
>
> //this thread listen for incoming connections, for every connection
> (there are only a few connections), it creates another thread.
>
> UINT Listening( LPVOID pParam )
> {
> SOCKET sListen = WSASocket(AF_INET, SOCK_STREAM, 0, NULL, 0,
> WSA_FLAG_OVERLAPPED);
> SOCKET sClient1 = WSASocket(AF_INET, SOCK_STREAM, 0, NULL, 0, 0);
> SOCKET sClient2 = WSASocket(AF_INET, SOCK_STREAM, 0, NULL, 0, 0);
>
> //bind and listen, ok
>
> //1 er. cliente
> if (SOCKET_ERROR == (sClient1 = accept(sListen,
> (sockaddr *)(&cliente), &longitud))){
> //...
> }
> //create a thread and pass information in the pParam parameter
> SocketAtado * Socket = new SocketAtado(pConexion->m_pCWnd, sClient1,
> &cliente, SocketAtado::CLIENTE1);
> CWinThread *cliente1 = AfxBeginThread(HiloCliente,
> (void *)(Socket)
> , 0, 0, 0, 0);
> //accept another connections
> //...
> return 1;
> }
> UINT HiloCliente( LPVOID pParam )
> {
> //recover information
> SocketAtado *socketAtado = (SocketAtado *)pParam;
> //...
> int Index = 0;
> DWORD bytesTransferidos = 0, bytesRecibidos = 0;
> DWORD Flags = 0;
> DWORD totalRecibidos = 0;
> DWORD totalFichero = -1;
> char buffer[500];
>
> //read a xml file, everything is ok right now
> bool pasada = false, sizeEncontrado = false;
> while((totalRecibidos + 2) != totalFichero ){
> }
> //create the response
> //...
> std::stringstream str;
> //...
> //and send, no matter i use sinchronous or asynchronous mode:
> // 1.- If i use synchronous mode send(,,,); returns inmediatly and
> WSAGetLastError() report no errors. However at the time the
> //send is accomplished, the client receives nothing. Even more, if
> the client is down, it still can send.
> // 2.- If i use an asynchronous mode, WSAWaitForMultipleEvents
> doesn't wait and always returns although the situation of the client
> //is the same as that descrived above, the events are off but they
> are triggered when WSASend is called although the client isn't
> listening
> //at that very moment
> }



Relevant Pages