Created
February 22, 2015 16:47
-
-
Save culurciello/0439d9ba6a69c3a36109 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-------------------------------------------------------------------------------- | |
-- 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