diff options
author | 2016-02-21 11:48:45 +0100 | |
---|---|---|
committer | 2016-02-21 11:48:45 +0100 | |
commit | cc24a339d8c0517259084b5c178d784626ba965c (patch) | |
tree | 9868e9687b5802ae0a3733712a3bbeb3bc75c953 /3rdparty/luv/examples/uvbook/tcp-echo-client.lua | |
parent | b5daabda5495dea5c50e17961ecfed2ea8619d76 (diff) |
Merge remote-tracking branch 'refs/remotes/mamedev/master'
Second attempt
Diffstat (limited to '3rdparty/luv/examples/uvbook/tcp-echo-client.lua')
-rw-r--r-- | 3rdparty/luv/examples/uvbook/tcp-echo-client.lua | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/3rdparty/luv/examples/uvbook/tcp-echo-client.lua b/3rdparty/luv/examples/uvbook/tcp-echo-client.lua new file mode 100644 index 00000000000..40dd22a311f --- /dev/null +++ b/3rdparty/luv/examples/uvbook/tcp-echo-client.lua @@ -0,0 +1,21 @@ +local uv = require('luv') + + +local client = uv.new_tcp() +uv.tcp_connect(client, "127.0.0.1", 1337, function (err) + assert(not err, err) + uv.read_start(client, function (err, chunk) + assert(not err, err) + if chunk then + print(chunk) + else + uv.close(client) + end + end) + + uv.write(client, "Hello") + uv.write(client, "World") +end) +print('CTRL-C to break') +uv.run('default') +uv.loop_close() |