πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.csharpbuilder.language.csharp
Article #228

Re: C# to Delphi tcpclient data send/receive

#228
From: Francois PIETTE [ICS - MidWare]
Date: Sat, 22 Jul 2006 18:40
72 lines
2870 bytes
Try with this:

procedure TForm1.TcpClient1Receive(Sender: TObject; Buf: PAnsiChar;
 var DataLen: Integer);
var
begin
    if (Sender is TCustomIpClient) then
        memRecv.Lines.Add('Recd: ' + StrPas(Buf));
end;

btw: You may also want to use ICS component, specifically TWSocket instead 
of  TcpClient. See http://www.overbyte.be

-- 
francois.piette@overbyte.be
The author for the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be



"Nigel Scott" <mvsoft@telus.net> a οΏ½crit dans le message de news: 
44c25b64@newsgroups.borland.com...
> Using C3 out of  bds 2006 and Delphi7, I am having difficulty with 
> receiving intelliable data in the Delphi 7 app.  (Sending the other way is 
> intelliable).
>
>    if (outStream.CanWrite)
>    {
>      string sendMsg = "Good Day";
>       Byte[] data = System.Text.Encoding.ASCII.GetBytes(sendMsg);
>       this.outStream.Write(data, 0, data.Length);
>    }
>
> From the above, the receive event contains this
>
> procedure TForm1.TcpClient1Receive(Sender: TObject; Buf: PAnsiChar;
>  var DataLen: Integer);
> var
>  P: PChar;
> recvdString: String;
> begin
>    if (Sender is TCustomIpClient) then
>    begin
>         P := @Buf;
>        recvdString := PChar(P);
>        memRecv.Lines.Add('Recd: ' + recvdString);
>    end;
> ....
> end;
>
>
> The following in an onConnect event produces similar problems
> var
>  A: array[0..79] of Char;
>  P: PChar;
>  bufsize: Integer;
> begin
>      TCustomIpClient(Sender).ReceiveBuf(A, bufsize, 0);
>      if not (bufsize = 0) then
>      begin
>        P := @A[0];
>        recvdString := string(P);
>      end;
> .....
> end;
>
> I apologize if there is a more suitable newsgroup.
>
> Nigel Scott, MVS
>
> 
Technical Details
Message-ID: <44c2715e$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!news.albasani.net!reader.uucp.at!feeder02.uucp.at!newsfeed.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mail
References: <44c25b64@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,2f9b2018e28731ee
X-Google-Attributes: gid1efe35,public
X-Google-Language: ENGLISH,ASCII
From: "Francois PIETTE [ICS - MidWare]" <francois.piette@overbyte.be>
Newsgroups: borland.public.csharpbuilder.language.csharp
References: <44c25b64@newsgroups.borland.com>
Subject: Re: C# to Delphi tcpclient data send/receive
Date: Sat, 22 Jul 2006 20:40:27 +0200
Lines: 74
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2869
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 81.243.169.75
Message-ID: <44c2715e$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1153593694 81.243.169.75 (22 Jul 2006 11:41:34 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!news.albasani.net!reader.uucp.at!feeder02.uucp.at!newsfeed.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mail