Click here to Skip to main content
15,915,509 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Mark Salsbery6-Aug-08 6:49
Mark Salsbery6-Aug-08 6:49 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Kiran Satish6-Aug-08 10:00
Kiran Satish6-Aug-08 10:00 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Mark Salsbery7-Aug-08 5:41
Mark Salsbery7-Aug-08 5:41 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Kiran Satish7-Aug-08 6:45
Kiran Satish7-Aug-08 6:45 
AnswerRe: Help on Multi-Threaded applicaiton Pin
Simon Cooke15-Oct-08 21:52
Simon Cooke15-Oct-08 21:52 
GeneralRe: Help on Multi-Threaded applicaiton Pin
Kiran Satish6-Aug-08 13:33
Kiran Satish6-Aug-08 13:33 
QuestionGet Running Application's Main Window Pin
vikrant kpr27-Jun-08 12:22
vikrant kpr27-Jun-08 12:22 
Questionwinsock2 recv() returns empty buffer, but correct number of bytes received Pin
Member 427345427-Jun-08 11:14
Member 427345427-Jun-08 11:14 
I wrote a TCP client class that reads known number of bytes. I stepped thru the server code to make sure that the server is sending correct number of bytes, and dumping the content of transmit buffer to the screen. The client seems to receive the data fine, as the recv() returns the same number of bytes sent by the server. But the content of receive buffer is empty. Here's the client code fragment for the read:

// create manual reset event for the received data
WSAEVENT hDataRcvdEvent = WSACreateEvent();

if (WSAEventSelect(sServer, hDataRcvdEvent, FD_READ) == SOCKET_ERROR) {
    errCode = WSAGetLastError();
    cerr << "Unable to create event object (WSAEventSelect): " << errCode << endl;
}
// else wait for the received data
else {
    do{
        // if event object is signaled wait for data received event for 5 seconds
        // (assumes server is already running)
        if (WSAWaitForMultipleEvents(1, &hDataRcvdEvent, FALSE, SERVER_TIMEOUT, FALSE) == WSA_WAIT_EVENT_0) {
            // read more data from socket and append as necessary
            bytesRcvd = recv( sServer, rxBufPtr, bytesLeft, 0 );
            bytesLeft -= bytesRcvd;
            rxBufPtr += bytesRcvd;
            if (bytesRcvd > 0) {
                totalRead += bytesRcvd;
                cout << "\nReceived " << bytesRcvd << endl;  // debug echo (REMOVE!)
            }
        }
    // while message size is > packet size (broken up in multiple packets)
    }while (bytesRcvd > 0 && bytesExpected > bytesRcvd);
}


What's really bothering me is that this TCP client class worked just fine in different code that does the SAME thing, with only difference being what it does with RECEIVED data.

Another strange thing that's happening is that when receiving a large text data, the first recv() returns an empty buffer, but the second call to recv() returns the data that should have been returned in the first read. However, when receiving a small (< 32 bytes)data packet, subsequent read returns an empty receive buffer.
AnswerRe: winsock2 recv() returns empty buffer, but correct number of bytes received Pin
Mark Salsbery28-Jun-08 11:15
Mark Salsbery28-Jun-08 11:15 
QuestionOLE Automation server's knowledge of client(s) Pin
garyflet27-Jun-08 6:11
garyflet27-Jun-08 6:11 
AnswerRe: OLE Automation server's knowledge of client(s) Pin
Roger Stoltz27-Jun-08 7:42
Roger Stoltz27-Jun-08 7:42 
QuestionRe: OLE Automation server's knowledge of client(s) Pin
garyflet27-Jun-08 8:27
garyflet27-Jun-08 8:27 
AnswerRe: OLE Automation server's knowledge of client(s) Pin
Roger Stoltz30-Jun-08 1:31
Roger Stoltz30-Jun-08 1:31 
Questionerror appear Pin
sofia_11127-Jun-08 5:32
sofia_11127-Jun-08 5:32 
AnswerRe: error appear Pin
led mike27-Jun-08 5:37
led mike27-Jun-08 5:37 
GeneralRe: error appear [modified] Pin
sofia_11127-Jun-08 7:03
sofia_11127-Jun-08 7:03 
QuestionRe: error appear Pin
CPallini27-Jun-08 9:40
mveCPallini27-Jun-08 9:40 
AnswerRe: error appear Pin
sofia_11127-Jun-08 12:54
sofia_11127-Jun-08 12:54 
AnswerRe: error appear Pin
Hamid_RT30-Jun-08 18:30
Hamid_RT30-Jun-08 18:30 
QuestionExtending Exchange Server Pin
Steve Thresher27-Jun-08 3:38
Steve Thresher27-Jun-08 3:38 
AnswerRe: Extending Exchange Server Pin
led mike27-Jun-08 5:35
led mike27-Jun-08 5:35 
QuestionRemoving tab spaces using C++ source code Pin
Nandu_77b27-Jun-08 1:59
Nandu_77b27-Jun-08 1:59 
AnswerRe: Removing tab spaces using C++ source code Pin
CPallini27-Jun-08 2:10
mveCPallini27-Jun-08 2:10 
QuestionRe: Removing tab spaces using C++ source code Pin
Nandu_77b27-Jun-08 2:46
Nandu_77b27-Jun-08 2:46 
QuestionRe: Removing tab spaces using C++ source code Pin
SandipG 27-Jun-08 2:52
SandipG 27-Jun-08 2:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.