Thread View: borland.public.csharpbuilder.language.csharp
2 messages
2 total messages
Started by Nigel Scott
Sat, 22 Jul 2006 17:07
C# to Delphi tcpclient data send/receive
Author: Nigel Scott
Date: Sat, 22 Jul 2006 17:07
Date: Sat, 22 Jul 2006 17:07
47 lines
2101 bytes
2101 bytes
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
Re: C# to Delphi tcpclient data send/receive
Author: Francois PIETTE [ICS - MidWare]
Date: Sat, 22 Jul 2006 18:40
Date: Sat, 22 Jul 2006 18:40
72 lines
2870 bytes
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
>
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads