Click here to Skip to main content
15,916,463 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Selected text in memory Pin
Paul M Watt19-Apr-02 5:46
mentorPaul M Watt19-Apr-02 5:46 
GeneralRe: Selected text in memory Pin
Kemal OZLU19-Apr-02 13:04
Kemal OZLU19-Apr-02 13:04 
GeneralRe: Selected text in memory Pin
Paul M Watt19-Apr-02 13:47
mentorPaul M Watt19-Apr-02 13:47 
GeneralUnlimited Socket receive Pin
Kristian3318-Apr-02 21:17
Kristian3318-Apr-02 21:17 
GeneralRe: Unlimited Socket receive Pin
18-Apr-02 23:07
suss18-Apr-02 23:07 
GeneralRe: Unlimited Socket receive Pin
Jon Hulatt18-Apr-02 23:33
Jon Hulatt18-Apr-02 23:33 
GeneralRe: Unlimited Socket receive Pin
19-Apr-02 3:38
suss19-Apr-02 3:38 
GeneralRe: Unlimited Socket receive Pin
Albert Pascual19-Apr-02 6:49
sitebuilderAlbert Pascual19-Apr-02 6:49 
What about a simple way like that: Check for the size of the buffer return, if it is as big as your buffer, read the socket again and append it at the end of the buffer, keep doing that until the size returned is smaller than your buffer. That's the end of the packet!

Take a look at the code below:




unsigned char *BigBuff = NULL;
unsigned char buf[4096];
ULONG size = 4096;
ULONG rc = 0;
BOOL bMoreData = false;
ULONG TotalSize = 0;

do
{
bMoreData = true;

memset(&buf[0], 0, 4096);

rc = TcpRecv(SocAccepted, buf, size);
if ( rc == 0 )
{
goto end;
}

if ( rc == (ULONG)SOCKET_ERROR )
goto end;

TotalSize = TotalSize + rc;

if ( BigBuff == NULL )
{
BigBuff = (unsigned char *) malloc (rc+10);
if ( !BigBuff )
return NULL;

memcpy(BigBuff, buf, rc);

}

else
{
unsigned char *p = NULL;

p = (unsigned char *)realloc(BigBuff, TotalSize);
if ( !p )
{
free( BigBuff );
return NULL;
}

BigBuff = p;

memcpy(&BigBuff[TotalSize-rc], buf, rc);
}


if ( rc == size )
bMoreData = true;



}while(bMoreData);

end:

return (&BigBuff[0]);
GeneralC/C++ compiler Pin
NicholasCougar18-Apr-02 19:43
NicholasCougar18-Apr-02 19:43 
GeneralRe: C/C++ compiler Pin
Ravi Bhavnani18-Apr-02 20:17
professionalRavi Bhavnani18-Apr-02 20:17 
GeneralRe: C/C++ compiler Pin
Michael P Butler18-Apr-02 22:14
Michael P Butler18-Apr-02 22:14 
QuestionTextExtent??? Pin
Manikandan18-Apr-02 18:03
Manikandan18-Apr-02 18:03 
AnswerRe: TextExtent??? Pin
Paul M Watt18-Apr-02 18:09
mentorPaul M Watt18-Apr-02 18:09 
AnswerRe: TextExtent??? Pin
l a u r e n18-Apr-02 21:01
l a u r e n18-Apr-02 21:01 
GeneraltimeSetEvent Pin
Marcus Spitzmiller18-Apr-02 17:17
Marcus Spitzmiller18-Apr-02 17:17 
GeneralRe: Cool PE (.exe, .dll, .ocx) file resource tool Pin
Christian Graus18-Apr-02 16:51
protectorChristian Graus18-Apr-02 16:51 
QuestionHow to convert to twips...? Pin
Sprudling18-Apr-02 16:22
Sprudling18-Apr-02 16:22 
AnswerRe: How to converting to twips...? Pin
Michael Dunn18-Apr-02 17:04
sitebuilderMichael Dunn18-Apr-02 17:04 
GeneralRe: How to converting to twips...? Pin
Sprudling19-Apr-02 5:15
Sprudling19-Apr-02 5:15 
AnswerMay be this one help you... Pin
Manikandan18-Apr-02 18:07
Manikandan18-Apr-02 18:07 
AnswerRe: How to convert to twips...? Pin
l a u r e n18-Apr-02 21:04
l a u r e n18-Apr-02 21:04 
GeneralAligning text in CRichEditCtrl Pin
Sprudling18-Apr-02 15:43
Sprudling18-Apr-02 15:43 
GeneralRe: Aligning text in CRichEditCtrl Pin
Niklas L18-Apr-02 22:32
Niklas L18-Apr-02 22:32 
GeneralRe: Aligning text in CRichEditCtrl Pin
18-Apr-02 22:59
suss18-Apr-02 22:59 
GeneralRe: Aligning text in CRichEditCtrl Pin
Sprudling19-Apr-02 5:19
Sprudling19-Apr-02 5:19 

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.