Recent

Author Topic: tclientsocket conversion to lnet tltcpcompent .. onrecieve how  (Read 6214 times)

olddelphiuser

  • New Member
  • *
  • Posts: 10
I am converting a delphi program to lazarus. The Delphi program uses tclientsocket.

the on read event is


procedure TClientTestFrm.ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);

xxxxx
begin

   buffer_len:=socket.ReceiveLength;  // so it is set on the repeat loop
  while buffer_len>0 do
    begin
    inbuffer:=@FrameData[bytes_rcvd];   // where to put the data
      block_bytes_rcvd:=(socket.ReceiveBuf(inBuffer^,buffer_len));
    bytes_rcvd:=bytes_rcvd+block_bytes_rcvd;
    if (block_bytes_rcvd<0) and (buffer_len>0)  then
     ShowMessage ('No data');

// check for sync data and react
// check for end of data and react


   buffer_len:=socket.ReceiveLength;  // is there another block
  end; //while
end;

I don't see the equivalent of the ..ReceiveLength even though the
.get requires a size input. 

how does the onRecieve and get work in lnet.

thanks very much.

robert

Leledumbo

  • Hero Member
  • *****
  • Posts: 8776
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: tclientsocket conversion to lnet tltcpcompent .. onrecieve how
« Reply #1 on: June 30, 2010, 08:38:07 pm »
Why don't you check the examples? Check the server ones

olddelphiuser

  • New Member
  • *
  • Posts: 10
Re: tclientsocket conversion to lnet tltcpcompent .. onrecieve how
« Reply #2 on: June 30, 2010, 09:01:06 pm »

That isn't very helpful. why bother posting. If there is a clear example, I must have missed it. And if you are familiar with it you should post it or point to it. I notice that a lot of the replies on this board are not very helpful. I wonder if the posters actually know the answer or just want to post a reply...

I solved the problem. I continue reading until ".get" returns 0 bytes read. I give it a large buffer size.

This doesn't seem very elegant compared to looking at how much data needs to be read as you can with tclientsocket. And since I was porting a Delphi program I was looking for a similar method.

robert



 

TinyPortal © 2005-2018