box.iproto.send()
-
box.iproto.
send
(sid, header[, body])¶ Since version 2.11.0. Send an IPROTO packet over the session’s socket with the given MsgPack header and body. The header and body contain exported IPROTO constants from the box.iproto() submodule. Possible IPROTO constant formats:
- a lowercase constant without the
IPROTO_
prefix (schema_version
,request_type
) - a constant from the corresponding box.iproto subnamespace (
box.iproto.SCHEMA_VERSION
,box.iproto.REQUEST_TYPE
)
The function works for binary sessions only. For details, see box.session.type().
Parameters: - sid (
number
) – the IPROTO session identifier (see box.session.id()) - header (
table|string
) – a request header encoded as MsgPack - body (
table|string|nil
) – a request body encoded as MsgPack
Return: 0 on success, otherwise an error is raised
Rtype: number
Possible errors:
ER_SESSION_CLOSED
– the session is closed.ER_NO_SUCH_SESSION
– the session does not exist.ER_MEMORY_ISSUE
– out-of-memory limit has been reached.ER_WRONG_SESSION_TYPE
– the session type is not binary.
For details, see src/box/errcode.h.
Examples:
Send a packet using Lua tables and string IPROTO constants as keys:
box.iproto.send(box.session.id(), { request_type = box.iproto.type.OK, sync = 10, schema_version = box.info.schema_version }, { data = 1 })
Send a packet using Lua tables and numeric IPROTO constants:
box.iproto.send(box.session.id(), { [box.iproto.key.REQUEST_TYPE] = box.iproto.type.OK, [box.iproto.key.SYNC] = 10, [box.iproto.key.SCHEMA_VERSION] = box.info.schema_version }, { [box.iproto.key.DATA] = 1 })
Send a packet that contains only the header:
box.iproto.send(box.session.id(), { request_type = box.iproto.type.OK, sync = 10, schema_version = box.info.schema_version })
- a lowercase constant without the