Forums » Bugs

Send on TCPSocket can crash game

Jul 13, 2008 mr_spuck link
local sock = TCPSocket()

local function ch()
 -- sock:GetSocketError()
 -- sock:Recv()

  console_print("CONNECT "..tostring(sock:Send("bla")))

  sock:Disconnect()
end
sock:SetWriteHandler(ch)
sock:Connect("localhost", 1234)

Assuming nothing is running on 1234. If any of the commented out lines are uncommented the game crashes if I run this script under 32bit linux. It's normally easy to avoid but it's kind of strange that it crashes the game..

EDIT:
doh ..here's an even simpler case. This one pops up the bug reporter.. above doesn't:
local sock = TCPSocket()
sock:Send("bla")
Jul 13, 2008 blacknet link
looks like :Send is undeclared at that point, so an non-handled condition.
Jul 14, 2008 mr_spuck link
No.. Send is declared in both cases. Otherwise the interpreter would complain. Inserting a print(sock.Send) shows that too.