Code: Select all
file = io.open(getloc, "rb")
if file then
incomingSocket:send("HTTP/1.0 200 OK\r\nContent-Type: " .. type .. "\r\n\r\n") -- Mime type was set earlier, for a PNG it will be image/png
f_size = fileSize(file) -- Uses a fileSize function I declared
graphicsPrint("File size is: " .. f_size .. "\n")
graphicsPrint("Sending file")
c_count = 0
chunksize = 128
bytes_read = 0
while true do
bytes = file:read(chunksize)
if bytes ~= nil then
incomingSocket:send(bytes)
end
c_count = c_count + 1
graphicsPrint(".")
System.sleep(5)
bytes_read = bytes_read + chunksize
if bytes_read >= f_size then break end
end
graphicsPrint("\nSent a file with " .. c_count .. " chunks of " .. chunksize .. " bytes.\n")
file:close()
end
Is this a bug in the WLAN functions, or is there some way for me to package my binary data so it stays intact when I send it? Thanks in advance.