socket:send() chokes on larger data
Posted: Fri Nov 28, 2014 8:22 am
Strange things happen when sending data longer than 2 physical packets...
making a request gives this result:
.. and fires the on:("sent") event 2 times. Looking at the network traffic (dumpfile attached) - there are 3 packets actually sent, the second ending with "122" (see the last line of the output above), the third one holds the last line actually sent: "500 12345678901234567890".
The count of lines sent doesn't matter as long as it's more data than fits in exactly two packets...
Additionally - enabling the "conn:close()" statement results in firing no "sent"-event at all but indeed sends the first packet (in the example above, the last lines received are:
Thomas
Code: Select all
srv=net.createServer(net.TCP)
srv:listen(666,function(conn)
conn:on("sent",function(conn)
print("packet sent")
end)
conn:on("receive",function(conn,payload)
for i=1,500,1
do
conn:send(tostring(i) .. " 12345678901234567890\n")
end
-- conn:close()
end)
end)
making a request gives this result:
Code: Select all
1 12345678901234567890
2 12345678901234567890
[ .... many more lines ...]
118 12345678901234567890
119 12345678901234567890
120 12345678901234567890
121 12345678901234567890
122500 12345678901234567890
.. and fires the on:("sent") event 2 times. Looking at the network traffic (dumpfile attached) - there are 3 packets actually sent, the second ending with "122" (see the last line of the output above), the third one holds the last line actually sent: "500 12345678901234567890".
The count of lines sent doesn't matter as long as it's more data than fits in exactly two packets...
Additionally - enabling the "conn:close()" statement results in firing no "sent"-event at all but indeed sends the first packet (in the example above, the last lines received are:
Code: Select all
121 12345678901234567890
122
Thomas