diff options
| author | Sam Roberts <vieuxtech@gmail.com> | 2012-02-27 13:26:23 -0800 |
|---|---|---|
| committer | Sam Roberts <vieuxtech@gmail.com> | 2012-04-11 13:54:01 -0700 |
| commit | 8bb542baaf30874479b83d37af2fea5fa84d0a8e (patch) | |
| tree | 117d706140ee622565fa1c671c5469cb7f30fdac /test | |
| parent | 0716cb868e847bb9f66c659f8662d905ba012de8 (diff) | |
| download | luasocket-8bb542baaf30874479b83d37af2fea5fa84d0a8e.tar.gz luasocket-8bb542baaf30874479b83d37af2fea5fa84d0a8e.tar.bz2 luasocket-8bb542baaf30874479b83d37af2fea5fa84d0a8e.zip | |
Support getoption method for tcp objects.
Diffstat (limited to 'test')
| -rwxr-xr-x | test/tcp-getoptions | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/tcp-getoptions b/test/tcp-getoptions new file mode 100755 index 0000000..f9b3d1b --- /dev/null +++ b/test/tcp-getoptions | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | #!/usr/bin/env lua | ||
| 2 | |||
| 3 | require"socket" | ||
| 4 | |||
| 5 | port = 8765 | ||
| 6 | |||
| 7 | function options(o) | ||
| 8 | print("options for", o) | ||
| 9 | |||
| 10 | for _, opt in ipairs{"keepalive", "reuseaddr", "tcp-nodelay"} do | ||
| 11 | print("getoption", opt, o:getoption(opt)) | ||
| 12 | end | ||
| 13 | |||
| 14 | print("getoption", "linger", | ||
| 15 | "on", o:getoption("linger").on, | ||
| 16 | "timeout", o:getoption("linger").timeout) | ||
| 17 | end | ||
| 18 | |||
| 19 | local m = socket.tcp() | ||
| 20 | |||
| 21 | options(m) | ||
| 22 | |||
| 23 | assert(m:bind("*", port)) | ||
| 24 | assert(m:listen()) | ||
| 25 | |||
| 26 | options(m) | ||
| 27 | |||
| 28 | m:close() | ||
| 29 | |||
| 30 | local m = socket.bind("*", port) | ||
| 31 | |||
| 32 | options(m) | ||
| 33 | |||
| 34 | local c = socket.connect("localhost", port) | ||
| 35 | |||
| 36 | options(c) | ||
| 37 | |||
| 38 | local s = m:accept() | ||
| 39 | |||
| 40 | options(s) | ||
| 41 | |||
