Difference between revisions of "Talk:lNet"

From Lazarus wiki
Jump to navigationJump to search
 
Line 12: Line 12:
 
<BR>
 
<BR>
 
----
 
----
 +
 +
Hi,
 +
 +
You need to "send" in a loop until send fails (returns 0). Only then you know that you can't send so "OnCanSend" will get fired again. This is perhaps a bit confusing, but the meaning of "OnCanSend" is what is called "edge-triggered" in that it will fire ONLY when the status changes from "I can still send" into "I can't send anymore".
 +
 +
So basicly you should add an inner loop which sends until Send returns 0 or all data is sent.
 +
 +
If you need to see in code, look at the lftpclient example, which does this when sending files to the server.

Revision as of 21:19, 7 November 2006

Hi,
I have some difficulties to use onCanSend property on a TLUDPComponent.
I wanted to use it to send large data streams on the UDP socket.
So I pointed the LUDP.onCanSend on my callback procedure (which will send packet by packet the large data stream) and initialized the transfer by calling the Loopback procedure for each socket.
I was expecting that once the first packet will have been sent, the call back procedure will be fired up again... but nothing.
I was just able to send one packet (relatively small actually: 256 bytes) and that's it!

Could someone tell me what's missing?
Thanks
JYL


Hi,

You need to "send" in a loop until send fails (returns 0). Only then you know that you can't send so "OnCanSend" will get fired again. This is perhaps a bit confusing, but the meaning of "OnCanSend" is what is called "edge-triggered" in that it will fire ONLY when the status changes from "I can still send" into "I can't send anymore".

So basicly you should add an inner loop which sends until Send returns 0 or all data is sent.

If you need to see in code, look at the lftpclient example, which does this when sending files to the server.