Created
April 9, 2019 10:03
-
-
Save RunsFor/cd28605c8c85cdaaa2300a14f2a7055f to your computer and use it in GitHub Desktop.
This gist shows inconsistent behaviour of tarantool's socket:receive function which internally uses different buffers for different types of calls
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
Tarantool 2.1.1-434-g881c7b59b | |
type 'help' for interactive help | |
tarantool> socket = require('socket') | |
--- | |
... | |
tarantool> fiber = require'fiber' | |
--- | |
... | |
tarantool> chan = fiber.channel() | |
--- | |
... | |
tarantool> fn = function(s) counter = 0; while true do s:write((tostring(counter)):rep(chan:get())); counter = counter + 1 end end | |
--- | |
... | |
tarantool> socket.tcp_server('0.0.0.0', 8888, fn) | |
started | |
--- | |
- fd: 6 | |
name: | |
host: 0.0.0.0 | |
family: AF_INET | |
type: SOCK_STREAM | |
protocol: tcp | |
port: 8888 | |
- host: 0.0.0.0 | |
family: AF_INET | |
type: SOCK_STREAM | |
protocol: tcp | |
port: 8888 | |
... | |
tarantool> s = socket.connect('localhost', 8888) | |
--- | |
... | |
tarantool> chan:put(5) | |
--- | |
- true | |
... | |
tarantool> chan:put(5) | |
--- | |
- true | |
... | |
tarantool> s:receive(5) | |
--- | |
- '00000' | |
... | |
tarantool> chan:put(5) | |
--- | |
- true | |
... | |
tarantool> s:settimeout(1) | |
--- | |
- 1 | |
... | |
tarantool> s:receive('*a') | |
--- | |
- '22222' | |
... | |
tarantool> s:receive(5) | |
--- | |
- '11111' | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment