Forum > Networking and Web Programming

tclientsocket conversion to lnet tltcpcompent .. onrecieve how


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);


   buffer_len:=socket.ReceiveLength;  // so it is set on the repeat loop
  while buffer_len>0 do
    inbuffer:=@FrameData[bytes_rcvd];   // where to put the data
    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

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.


Why don't you check the examples? Check the server ones


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.



[0] Message Index

Go to full version