🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #3257

Re: i need ideas/comments with tclientsocket

#3257
From: Alfred
Date: Tue, 01 Nov 2005 01:24
41 lines
2358 bytes
>I have tryed a ProcessPacket routine like :
>void__fastcall TForm1::ProcessPacket(TCustomWinSocket *Socket, void *Data, int DataLength)
>{
>        // process Data as needed...
>        char *a = new char[DataLength];
>        a = (char*)Data;
>        Memo->Lines->Add(AnsiString(a,DataLength));
>        delete[] a;
>}
>
>It dont work.. why not ? Sender program send an example with :
>        char *buf=new char[10];
>        buf = "1234567890";
>        int size=10;
>
>        Socket->SendBuf ( &size, sizeof(int) );
>        Socket->SendBuf ( buf , size );
>
>and the receiver write only not ascii chars. What is wrong ?

Fixed it, it was : ProcessPacket(TCustomWinSocket *Socket, LPBYTE *Data, int DataLength) so it is LPBYTE not void* .
A new problem appairs now when i receive half package each time, i write in the Memo the first 5 chars correctly and the last 5 in a not ascii chars..

Here is the code used in the sender :
   char *buf=new char[10];
   buf = "12345";

   Memo->Lines->Add("invio 1");
   int size=10;
   Socket->SendBuf ( &size, sizeof(int));
   Socket->SendBuf(buf,5);

   Sleep(3000); // to be sure it send data in 2 different package
   buf = "67890";
   Memo->Lines->Add("invio 2");
   Socket->SendBuf(buf,5);

Any idea ?
Thank you very much, you all helped my a lot :)
Alfred
Technical Details
Message-ID: <4366d1f6@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <43662baf$1@newsgroups.borland.com> <43667112$1@newsgroups.borland.com> <4366ccd3$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,5c33b8c6a9ca7fdb
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Alfred" <alf@no.spam.not.valid.email>
Sender: "Alfred" <alf@no.spam.not.valid.email>
Reply-To: "Alfred" <alf@no.spam.not.valid.email>
Subject: Re: i need ideas/comments  with tclientsocket
Newsgroups: borland.public.cppbuilder.internet.socket
X-User-Info: 82.52.136.128     
References: <43662baf$1@newsgroups.borland.com> <43667112$1@newsgroups.borland.com> <4366ccd3$1@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <4366d1f6@newsgroups.borland.com>
Date: 31 Oct 2005 18:24:54 -0700
X-Trace: newsgroups.borland.com 1130811894 207.105.83.66 (31 Oct 2005 18:24:54 -0700)
Lines: 41
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail