summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/luv/examples/uvbook/tcp-echo-client.lua
blob: 40dd22a311fab5637b65169b7e13832661e8182c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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()