Skip to content

Instantly share code, notes, and snippets.

@culurciello
Created February 22, 2015 16:47
Show Gist options
  • Save culurciello/0439d9ba6a69c3a36109 to your computer and use it in GitHub Desktop.
Save culurciello/0439d9ba6a69c3a36109 to your computer and use it in GitHub Desktop.
--------------------------------------------------------------------------------
-- E. Culurciello, October 2014
-- socket test in node.js and Lua
--------------------------------------------------------------------------------
require 'image'
local async = require 'async'
-- tcp client:
async.tcp.connect({host='127.0.0.1', port=6969}, function(client)
-- Write something
for i=1,100 do
client.write('something .. '..i..' ')
end
-- Callbacks
client.ondata(function(chunk)
print('received: ' .. chunk)
client.close()
end)
-- Done:
client.onend(function()
print('connection closed...')
end)
end)
async.repl()
async.go()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment