Click here to Skip to main content
15,885,366 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how to implement OnPaint() in activex control Pin
ScottMcP13-Jun-11 11:24
ScottMcP13-Jun-11 11:24 
Question":" in struct Pin
Pranit Kothari12-Jun-11 23:15
Pranit Kothari12-Jun-11 23:15 
AnswerRe: ":" in struct Pin
వేంకటనారాయణ(venkatmakam)12-Jun-11 23:24
వేంకటనారాయణ(venkatmakam)12-Jun-11 23:24 
AnswerRe: ":" in struct Pin
Malli_S13-Jun-11 1:25
Malli_S13-Jun-11 1:25 
QuestionWrong icon on title bar Pin
Lianqing12-Jun-11 6:15
Lianqing12-Jun-11 6:15 
AnswerRe: Wrong icon on title bar Pin
Luc Pattyn12-Jun-11 7:06
sitebuilderLuc Pattyn12-Jun-11 7:06 
AnswerRe: Wrong icon on title bar Pin
MicroVirus13-Jun-11 7:45
MicroVirus13-Jun-11 7:45 
QuestionWSARecv and recv Pin
csrss12-Jun-11 2:54
csrss12-Jun-11 2:54 
Hi. Lets say, we got such 2 scenarios where we are receiving data over a socket:

1. Using WSARecv

CHAR Buffer[1024];
WSABUF wsaBuffer;
DWORD dwBytesRecved = 0;
wsaBuffer.buf = (char *)Buffer;
wsaBuffer.len = sizeof(Buffer);
OVERLAPPED overLap;
::RtlSecureZeroMemory(&overLap, sizeof(overLap));
DWORD dwFlags = 0;
::WSARecv(sock, &wsaBuffer, 1, &dwBytesRecved, &dwFlags, &overLap, NULL);
wsaBuffer.buf[dwBytesRecved] = '\0';
cout << wsaBuffer.buf << ", Bytes: " << dwBytesRecved << endl;


2. And this one, using recv

CHAR Buffer[1024];
int recved = ::recv(sock, Buffer, size, 0);
Buffer[recved] = '\0';
cout <<  Buffer  << ", Bytes: " << recved << endl;


In both cases, we are receiving only one buffer. (WSABUF allows to specify more then 1 recv buffer).

And now, in case of recv, i can do something like this:
1. i got my recv buffer size, lets say 1024 bytes and doing recv.
2. Ok, i got some data and its length is 512 bytes and it has been copied to my recv buffer. But i know, that i should receive 1024 bytes of data.
3. So i am going to recv data in a loop until all 1024 bytes arrived.
4. Ok, i got some data again and it seems like it is next 512 bytes, but this time i am calling recv like this:

int recved = ::recv(sock, Buffer + already_received_number_of_bytes, size, 0);


So the rest of received data is appended to my recv buffer and in the end my recv buffer contains all data.

The question is: how can i do this with WSARecv ?
Thanks.
011011010110000101100011011010000110100101101110
0110010101110011

QuestionIs it possible to make an application to show a modeless dialog and wait there(without executing the next statement) until the modeless dialog is closed Pin
manoharbalu10-Jun-11 19:54
manoharbalu10-Jun-11 19:54 
AnswerRe: Is it possible to make an application to show a modeless dialog and wait there(without executing the next statement) until the modeless dialog is closed Pin
Richard MacCutchan10-Jun-11 22:53
mveRichard MacCutchan10-Jun-11 22:53 
QuestionHow to disable a button control in a modal dialog Pin
manoharbalu10-Jun-11 19:51
manoharbalu10-Jun-11 19:51 
AnswerRe: How to disable a button control in a modal dialog Pin
Richard MacCutchan10-Jun-11 22:52
mveRichard MacCutchan10-Jun-11 22:52 
AnswerRe: How to disable a button control in a modal dialog Pin
Albert Holguin12-Jun-11 17:13
professionalAlbert Holguin12-Jun-11 17:13 
QuestionGantt chart Pin
Jokcy10-Jun-11 16:22
Jokcy10-Jun-11 16:22 
AnswerRe: Gantt chart Pin
Richard MacCutchan10-Jun-11 22:50
mveRichard MacCutchan10-Jun-11 22:50 
GeneralRe: Gantt chart Pin
Jokcy17-Jun-11 2:56
Jokcy17-Jun-11 2:56 
AnswerRe: Gantt chart Pin
Cedric Moonen13-Jun-11 0:02
Cedric Moonen13-Jun-11 0:02 
GeneralRe: Gantt chart Pin
Jokcy17-Jun-11 2:55
Jokcy17-Jun-11 2:55 
AnswerRe: Gantt chart Pin
ThatsAlok13-Jun-11 20:51
ThatsAlok13-Jun-11 20:51 
GeneralRe: Gantt chart Pin
Jokcy17-Jun-11 2:58
Jokcy17-Jun-11 2:58 
Question[Win32]Scroll bitmap Pin
Member 296547110-Jun-11 12:47
Member 296547110-Jun-11 12:47 
AnswerRe: [Win32]Scroll bitmap Pin
Mark Salsbery10-Jun-11 16:44
Mark Salsbery10-Jun-11 16:44 
Question[Win32] Threads communication Pin
Member 296547110-Jun-11 12:45
Member 296547110-Jun-11 12:45 
AnswerRe: [Win32] Threads communication Pin
Albert Holguin10-Jun-11 13:31
professionalAlbert Holguin10-Jun-11 13:31 
AnswerRe: [Win32] Threads communication Pin
lijiantao11-Jun-11 5:32
lijiantao11-Jun-11 5:32 

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.