Forum > Networking and Web Programming
tclientsocket conversion to lnet tltcpcompent .. onrecieve how
(1/1)
olddelphiuser:
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:
Why don't you check the examples? Check the server ones
olddelphiuser:
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
Navigation
[0] Message Index