A simple question of lNet lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- senglit · 2020-06-10 14:01 Hi all, What happen when I send a "TCP.SendMessage(string,TCP.Iterator)"  while  "not (ssCanSend in TCP.Iterator.SocketState)"? The message will be dumped or it will be added into a queue and send when ssCanSend  ok? Or it will wait there untill ssCanSend is true and send message? ---------------------------------------------------------------------- MarkMLl · 2020-06-10 14:12 You might be better asking at https://github.com/almindor/lnet Note warning at https://wiki.freepascal.org/lNet#Overview I'd love it if this package were better supported, since I think that basic network protocols are so pervasive these days that they're worth having in the standard libraries. I'm using the Telnet stuff in a couple of places, and to be honest the /only/ thing to be said for it is that it doesn't introduce an external dependency; I'm seriously considering replacing it with a state machine which could sit on top of whatever means of socket access best suits the remainder of the program. MarkMLl ---------------------------------------------------------------------- rvk · 2020-06-10 14:40 Maybe I don't see the point... But isn't it so that this won't send anything???? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i while not (ssCanSend in TCP.Iterator.SocketState) do  TCP.SendMessage(string,TCP.Iterator); It will only do the loop while ssCanSend is NOT in TCP.Iterator.SocketState. And isn't SendMessage not 'blocking'. So it will try to send the message for a timeout time. And if it fails halfway through it will return the number of bytes really send. ---------------------------------------------------------------------- senglit · 2020-06-14 11:07 Quote from: rvk on June 10, 2020, 04:40:14 pmAnd isn't SendMessage not 'blocking'. So it will try to send the message for a timeout time. And if it fails halfway through it will return the number of bytes really send. I think you are right. Since SendMessage is a function which return an integer, it must wait there till it knows if data are sent or not. If the data are put in a queue and sent when ssCanSend is OK, the function can not give that integer result. ---------------------------------------------------------------------- MarkMLl · 2020-06-14 11:57 Quote from: senglit on June 14, 2020, 01:07:11 pmI think you are right. Since SendMessage is a function which return an integer, it must wait there till it knows if data are sent or not. If the data are put in a queue and sent when ssCanSend is OK, the function can not give that integer result. The TMyClass.OnCanSend() example at https://lnet.wordpress.com/usage/sockets-protocols-and-sending/ shows the way of sending recommended by lNet's author, and specifically allows that SendMessage() might return zero if nothing can be sent. MarkMLl