- be safe for either "ethernet v1" or "PPPoE", both take 8 bytes\r
- IPv6 header: 40 bytes (IPv4 is 20)\r
- TCP/UDP header: 20 bytes\r
+ packetbasesize is deprecated and should not be used anymore\r
}\r
packetbasesize = 1432;\r
- receivebufsize=packetbasesize*8;\r
+ receivebufsize=16384;\r
\r
var\r
absolutemaxs:integer=0;\r
{$ifdef mswindows}\r
sendflushlasterror:integer;\r
{$endif}\r
+\r
+ sendflushmaxwrite:integer;\r
+ //how much to write to the socket internally in one go. higher values allow faster throughput especially if latency is high\r
+ //but it also causes onsenddata to be called less often (typically once for every sendflushmaxwrite bytes)\r
+\r
function receivestr:tbufferstring; virtual;\r
procedure close;\r
procedure abort;\r
\r
var\r
firsttimer : tltimer ;\r
- firsttask , lasttask , currenttask : tltask ;\r
+ firsttask , lasttask : tltask ;\r
\r
numread : integer ;\r
mustrefreshfds : boolean ;\r
state := wsclosed;\r
fdhandlein := -1;\r
fdhandleout := -1;\r
+ sendflushmaxwrite := 16384;\r
end;\r
\r
destructor tlasio.destroy;\r
end;\r
datasentcalled := false;\r
\r
- lensent := sendq.get(data,packetbasesize*2);\r
+ lensent := sendflushmaxwrite;\r
+ if (lensent <= 0) then lensent := sendq.size;\r
+\r
+ lensent := sendq.get(data,lensent);\r
if assigned(data) then result := myfdwrite(fdhandleout,data^,lensent) else result := 0;\r
\r
if result = -1 then lensent := 0 else lensent := result;\r
{$ifndef mswindows}\r
procedure tltimer.resettimes;\r
begin\r
- gettimeofday(nextts);\r
+ gettimemonotonic(nextts);\r
{if not initialevent then} tv_add(nextts,interval);\r
end;\r
{$endif}\r
{$endif}\r
\r
procedure processtasks;//inline;\r
+var\r
+ currenttask:tltask;\r
begin\r
\r
while assigned(firsttask) do begin\r
if not assigned(firsttask) then lasttask := nil;\r
\r
if assigned(currenttask.handler) then currenttask.handler(currenttask.wparam,currenttask.lparam);\r
-\r
+ currenttask.free;\r
end;\r
currenttask := nil;\r
end;\r