tarantool / tarantool/doc

Fix socket.recv documentation.

Open
#3,206 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

factual error reference typo
Dominant language
CSS
Stars
15
Forks
49
Avg merge
1d 13h
Merged PRs (30d)
3

Description

Product: Tarantool
Root document: https://www.tarantool.io/en/doc/latest/reference/reference_lua/socket/#lua-function.socket_object.recv
SME: @ nshy

Info

https://www.tarantool.io/en/doc/latest/reference/reference_lua/socket/#lua-function.socket_object.recv

What's wrong?

Method returns nil on error with socket._errno set.

Code:

socket = require('socket')
s = socket('AF_UNIX', 'SOCK_DGRAM', 0)
-- should be error as socket is nonblocking
r = s:recv(1)
print(r)
print(s._errno)

Output

nil
11

Also in case of EOF it just receives empty string. There is no special EOF status.

socket = require('socket')
fio = require('fio')
fio.unlink('test.sock')
s = socket('AF_UNIX', 'SOCK_STREAM', 0)
assert(s)
assert(s:bind('unix/', 'test.sock'))
assert(s:listen())
c = socket.tcp_connect('unix/', 'test.sock')
assert(c)
print(c)
sc = s:accept()
assert(sc)
sc:write("4444")
d = c:recv(2)
assert(d)
print(d)
sc:shutdown(socket.SHUT_WR)
d = c:recv(2)
assert(d)
print(d)
d = c:recv(2)
assert(d)
assert(string.len(d) == 0)
print("EOF")
d = c:recv(2)
assert(d)
assert(string.len(d) == 0)
print("EOF")

Output:

fd 12, aka unix/:, peer unix/:test.sock
44
44
EOF
EOF

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open the socket.recv documentation at the linked Tarantool reference page and compare its description with the provided Lua examples. Document that errors return nil with socket._errno set, and that EOF returns an empty string without a special status; the examples should support the corrected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.