diff --git a/include/coio.h b/include/coio.h index 2948184f9a91f56a4009a8db434c730b0a2bb3c7..9427ac7cc77d25783e00a1ab775d57c377d6a4cf 100644 --- a/include/coio.h +++ b/include/coio.h @@ -49,11 +49,11 @@ coio_socket(struct ev_io *coio, int domain, int type, int protocol); void coio_connect(struct ev_io *coio, struct sockaddr_in *addr); -void +bool coio_connect_timeout(struct ev_io *coio, struct sockaddr_in *addr, socklen_t len, ev_tstamp timeout); -void +bool coio_connect_addrinfo(struct ev_io *coio, struct addrinfo *ai, ev_tstamp timeout); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7979c6c2fb7a554b5feaefe4e12f36430797ea50..6dbba7e4953e31a0ab8f4e86ca6a02da5b6957f0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -96,7 +96,7 @@ set (common_sources lua/slab.m lua/uuid.m lua/lua_ipc.m - lua/lua_io.m + lua/lua_socket.m lua/session.m ) diff --git a/src/coio.m b/src/coio.m index 93958802328441597516fa7d0df2e746054a2403..38523e019751785bcc562b8e7ba966eff2f33074 100644 --- a/src/coio.m +++ b/src/coio.m @@ -72,16 +72,20 @@ coio_connect(struct ev_io *coio, struct sockaddr_in *addr) /** * Connect to a host with a specified timeout. + * @retval true timeout + * @retval false connected */ -void +bool coio_connect_timeout(struct ev_io *coio, struct sockaddr_in *addr, socklen_t len, ev_tstamp timeout) { if (sio_connect(coio->fd, addr, len) == 0) - return; + return false; assert(errno == EINPROGRESS); - /* Wait until socket is ready for writing or - * timed out. */ + /* + * Wait until socket is ready for writing or + * timed out. + */ ev_io_set(coio, coio->fd, EV_WRITE); ev_io_start(coio); bool is_timedout = fiber_yield_timeout(timeout); @@ -89,16 +93,17 @@ coio_connect_timeout(struct ev_io *coio, struct sockaddr_in *addr, fiber_testcancel(); if (is_timedout) { errno = ETIMEDOUT; - tnt_raise(SocketError, :coio->fd in:"connect"); + return true; } int error = EINPROGRESS; socklen_t sz = sizeof(error); sio_getsockopt(coio->fd, SOL_SOCKET, SO_ERROR, &error, &sz); - if (error == 0) - return; - errno = error; - tnt_raise(SocketError, :coio->fd in:"connect"); + if (error != 0) { + errno = error; + tnt_raise(SocketError, :coio->fd in:"connect"); + } + return false; } /** @@ -107,39 +112,33 @@ coio_connect_timeout(struct ev_io *coio, struct sockaddr_in *addr, * * Coio should not be initialized. */ -void +bool coio_connect_addrinfo(struct ev_io *coio, struct addrinfo *ai, ev_tstamp timeout) { - struct addrinfo *a; - int error = 0; - ev_tstamp start, delay; evio_timeout_init(&start, &delay, timeout); - for (a = ai; a; a = a->ai_next) { + while (ai) { + struct sockaddr_in *addr = (struct sockaddr_in *) ai->ai_addr; @try { - coio_socket(coio, a->ai_family, a->ai_socktype, a->ai_protocol); + if (! evio_is_active(coio)) { + coio_socket(coio, ai->ai_family, + ai->ai_socktype, + ai->ai_protocol); - evio_setsockopt_tcp(coio->fd); - - coio_connect_timeout(coio, (struct sockaddr_in*)a->ai_addr, - a->ai_addrlen, delay); - return; - } @catch (FiberCancelException *e) { - evio_close(coio); - @throw; + evio_setsockopt_tcp(coio->fd); + } + return coio_connect_timeout(coio, addr, + ai->ai_addrlen, delay); } @catch (tnt_Exception *e) { - error = errno; ev_now_update(); evio_timeout_update(start, &delay); evio_close(coio); - continue; + ai = ai->ai_next; } - return; } - errno = error; - tnt_raise(SocketError, :coio->fd in:"connect_addrinfo"); + tnt_raise(SocketError, :coio->fd in:"connect_addrinfo(): exhausted addrinfo list"); } /** diff --git a/src/lua/init.m b/src/lua/init.m index 4f94747d2d8698fa562208c2b6accdc89b4a61c9..8eca308a1dbd78759009c02bd4fe48dfc6f0e0ee 100644 --- a/src/lua/init.m +++ b/src/lua/init.m @@ -45,7 +45,7 @@ #include "pickle.h" #include "fiber.h" #include "lua_ipc.h" -#include "lua_io.h" +#include "lua_socket.h" #include "lua/info.h" #include "lua/slab.h" #include "lua/stat.h" @@ -1368,7 +1368,7 @@ tarantool_lua_init() tarantool_lua_stat_init(L); tarantool_lua_ipc_init(L); tarantool_lua_uuid_init(L); - tarantool_lua_io_init(L); + tarantool_lua_socket_init(L); tarantool_lua_session_init(L); mod_lua_init(L); diff --git a/src/lua/lua_io.h b/src/lua/lua_socket.h similarity index 88% rename from src/lua/lua_io.h rename to src/lua/lua_socket.h index 3879a277976aec4b266e4d3dc8bbec35e0267f0c..663d5e3b5091162c73b950e98824cf0c7f914219 100644 --- a/src/lua/lua_io.h +++ b/src/lua/lua_socket.h @@ -1,5 +1,5 @@ -#ifndef TARANTOOL_LUA_IO_H_INCLUDED -#define TARANTOOL_LUA_IO_H_INCLUDED +#ifndef TARANTOOL_LUA_SOCKET_H_INCLUDED +#define TARANTOOL_LUA_SOCKET_H_INCLUDED /* * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following @@ -30,6 +30,6 @@ */ struct lua_State; -void tarantool_lua_io_init(struct lua_State *L); +void tarantool_lua_socket_init(struct lua_State *L); -#endif /* TARANTOOL_LUA_IO_H_INCLUDED */ +#endif /* TARANTOOL_LUA_SOCKET_H_INCLUDED */ diff --git a/src/lua/lua_io.m b/src/lua/lua_socket.m similarity index 88% rename from src/lua/lua_io.m rename to src/lua/lua_socket.m index efa8df4244da15fe5d561402ac0946921cc2f9e1..c1670dd14a81d40f4e8eb204ad24a1084c893d17 100644 --- a/src/lua/lua_io.m +++ b/src/lua/lua_socket.m @@ -26,7 +26,7 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include "lua_io.h" +#include "lua_socket.h" #include "lua.h" #include "lauxlib.h" #include "lualib.h" @@ -48,7 +48,7 @@ #include <lua/init.h> #include <stdlib.h> -static const char iolib_name[] = "box.io"; +static const char socketlib_name[] = "box.socket"; enum bio_error { ERESOLVE = -1 @@ -74,7 +74,7 @@ static int bio_pushsocket(struct lua_State *L, int socktype) { struct bio_socket *s = lua_newuserdata(L, sizeof(struct bio_socket)); - luaL_getmetatable(L, iolib_name); + luaL_getmetatable(L, socketlib_name); lua_setmetatable(L, -2); evio_clear(&s->coio); s->socktype = socktype; @@ -90,7 +90,7 @@ bio_checksocket(struct lua_State *L, int narg) /* avoiding unnecessary luajit assert */ if (lua_gettop(L) < narg) luaL_error(L, "incorrect method call"); - return luaL_checkudata(L, narg, iolib_name); + return luaL_checkudata(L, narg, socketlib_name); } static inline struct bio_socket * @@ -192,7 +192,7 @@ bio_resolve(int socktype, const char *host, const char *port, } static int -lbox_io_tostring(struct lua_State *L) +lbox_socket_tostring(struct lua_State *L) { struct bio_socket *s = bio_checksocket(L, -1); lua_pushfstring(L, "%d", s->coio.fd); @@ -205,7 +205,7 @@ lbox_io_tostring(struct lua_State *L) * Create SOCK_STREAM socket object. */ static int -lbox_io_tcp(struct lua_State *L) +lbox_socket_tcp(struct lua_State *L) { return bio_pushsocket(L, SOCK_STREAM); } @@ -216,7 +216,7 @@ lbox_io_tcp(struct lua_State *L) * Create SOCK_DGRAM socket object. */ static int -lbox_io_udp(struct lua_State *L) +lbox_socket_udp(struct lua_State *L) { return bio_pushsocket(L, SOCK_DGRAM); } @@ -227,7 +227,7 @@ lbox_io_udp(struct lua_State *L) * Close socket and reinitialize readahead buffer. */ static int -lbox_io_close(struct lua_State *L) +lbox_socket_close(struct lua_State *L) { struct bio_socket *s = bio_checksocket(L, -1); bio_close(s); @@ -245,7 +245,7 @@ lbox_io_close(struct lua_State *L) * 2. error: nil, status = "error", eno, estr */ static int -lbox_io_shutdown(struct lua_State *L) +lbox_socket_shutdown(struct lua_State *L) { struct bio_socket *s = bio_checkactivesocket(L, -1); int how = luaL_checkint(L, 2); @@ -263,7 +263,7 @@ lbox_io_shutdown(struct lua_State *L) * Return error code and error description. */ static int -lbox_io_error(struct lua_State *L) +lbox_socket_error(struct lua_State *L) { struct bio_socket *s = bio_checksocket(L, -1); return bio_pusherrorcode(L, s); @@ -281,7 +281,7 @@ lbox_io_error(struct lua_State *L) * 3. timeout: nil, status = "timeout", eno, estr */ static int -lbox_io_connect(struct lua_State *L) +lbox_socket_connect(struct lua_State *L) { struct bio_socket *s = bio_checksocket(L, 1); const char *host = luaL_checkstring(L, 2); @@ -302,14 +302,14 @@ lbox_io_connect(struct lua_State *L) evio_timeout_update(start, &delay); @try { /* connect to a first available host */ - coio_connect_addrinfo(&s->coio, ai, delay); + if (coio_connect_addrinfo(&s->coio, ai, delay)) + return bio_pusherror(L, s, ETIMEDOUT); } @catch (SocketError *e) { - /* case #2-3: error or timeout */ return bio_pusherror(L, s, errno); } @finally { freeaddrinfo(ai); } - /* case #1: Success */ + /* Success */ lua_settop(L, 1); return 1; } @@ -331,7 +331,7 @@ lbox_io_connect(struct lua_State *L) * */ static int -lbox_io_write(struct lua_State *L) +lbox_socket_write(struct lua_State *L) { struct bio_socket *s = bio_checkactivesocket(L, 1); size_t buf_size = 0; @@ -356,7 +356,7 @@ lbox_io_write(struct lua_State *L) } static inline int -lbox_io_read_ret(struct lua_State *L, struct bio_socket *s, char *buf, +lbox_socket_read_ret(struct lua_State *L, struct bio_socket *s, char *buf, size_t size, enum bio_status st) { lua_pushlstring(L, buf, size); @@ -365,7 +365,7 @@ lbox_io_read_ret(struct lua_State *L, struct bio_socket *s, char *buf, } static inline int -lbox_io_read_eof(struct lua_State *L, struct bio_socket *s, +lbox_socket_read_eof(struct lua_State *L, struct bio_socket *s, size_t sz) { size_t ret = ibuf_size(&s->iob->in); @@ -375,7 +375,7 @@ lbox_io_read_eof(struct lua_State *L, struct bio_socket *s, * read limit: return it with eof status * set. */ - lbox_io_read_ret(L, s, s->iob->in.pos, ret, BIO_EOF); + lbox_socket_read_ret(L, s, s->iob->in.pos, ret, BIO_EOF); s->iob->in.pos += ret; return 4; } @@ -397,7 +397,7 @@ lbox_io_read_eof(struct lua_State *L, struct bio_socket *s, * */ static int -lbox_io_read(struct lua_State *L) +lbox_socket_read(struct lua_State *L) { struct bio_socket *s = bio_checkactivesocket(L, 1); int sz = luaL_checkint(L, 2); @@ -414,7 +414,7 @@ lbox_io_read(struct lua_State *L) * * See case #4. */ if (s->eof) { - int rc = lbox_io_read_eof(L, s, sz); + int rc = lbox_socket_read_eof(L, s, sz); if (rc == -1) goto case_1; return rc; @@ -453,7 +453,7 @@ lbox_io_read(struct lua_State *L) enum bio_status st = (s->error == ETIMEDOUT) ? BIO_TIMEOUT : BIO_ERROR; - return lbox_io_read_ret(L, s, NULL, 0, st); + return lbox_socket_read_ret(L, s, NULL, 0, st); } /* in case of EOF from a client, return partly read chunk and @@ -466,7 +466,7 @@ lbox_io_read(struct lua_State *L) /* read chunk could be much bigger than limit, in * this case, don't return eof flag to a user until * whole data been read. */ - int rc = lbox_io_read_eof(L, s, sz); + int rc = lbox_socket_read_eof(L, s, sz); if (rc == -1) goto case_1; return rc; @@ -540,7 +540,7 @@ first_matched: if (unlikely(rs[i].sep_size == rs[i].pos + 1)) } static void -lbox_io_readline_cr(struct lua_State *L) +lbox_socket_readline_cr(struct lua_State *L) { /* emulate user passed {'\n'} as the separate table */ lua_newtable(L); @@ -550,7 +550,7 @@ lbox_io_readline_cr(struct lua_State *L) } static int -lbox_io_readline_ret(struct lua_State *L, struct bio_socket *s, +lbox_socket_readline_ret(struct lua_State *L, struct bio_socket *s, char *buf, size_t size, enum bio_status st, int sid) { @@ -561,21 +561,21 @@ lbox_io_readline_ret(struct lua_State *L, struct bio_socket *s, } static int -lbox_io_readline_opts(struct lua_State *L, unsigned int *limit, +lbox_socket_readline_opts(struct lua_State *L, unsigned int *limit, double *timeout) { int seplist = 2; switch (lua_gettop(L)) { case 1: /* readline() */ - lbox_io_readline_cr(L); + lbox_socket_readline_cr(L); break; case 2: /* readline(limit) readline({seplist}) */ if (lua_isnumber(L, 2)) { *limit = luaL_checkint(L, 2); - lbox_io_readline_cr(L); + lbox_socket_readline_cr(L); seplist = 3; } else if (! lua_istable(L, 2)) luaL_error(L, "box.io.readline: bad argument"); @@ -588,7 +588,7 @@ lbox_io_readline_opts(struct lua_State *L, unsigned int *limit, *limit = luaL_checkint(L, 2); if (lua_isnumber(L, 3)) { *timeout = luaL_checknumber(L, 3); - lbox_io_readline_cr(L); + lbox_socket_readline_cr(L); seplist = 4; break; } else if (! lua_istable(L, 3)) @@ -641,14 +641,14 @@ lbox_io_readline_opts(struct lua_State *L, unsigned int *limit, * */ static int -lbox_io_readline(struct lua_State *L) +lbox_socket_readline(struct lua_State *L) { struct bio_socket *s = bio_checkactivesocket(L, 1); bio_clearerr(s); unsigned int limit = UINT_MAX; double timeout = TIMEOUT_INFINITY; - int seplist = lbox_io_readline_opts(L, &limit, &timeout); + int seplist = lbox_socket_readline_opts(L, &limit, &timeout); int rs_size = lua_objlen(L, seplist); if (rs_size == 0) @@ -675,7 +675,7 @@ lbox_io_readline(struct lua_State *L) /* case #4: user limit reached */ if (bottom == limit) { - lbox_io_readline_ret(L, s, s->iob->in.pos, bottom, + lbox_socket_readline_ret(L, s, s->iob->in.pos, bottom, BIO_LIMIT, 0); s->iob->in.pos += bottom; return 5; @@ -693,7 +693,7 @@ lbox_io_readline(struct lua_State *L) * is fully traversed. */ eof: if (s->eof) { - lbox_io_readline_ret(L, s, s->iob->in.pos, bottom, + lbox_socket_readline_ret(L, s, s->iob->in.pos, bottom, BIO_EOF, 0); s->iob->in.pos += bottom; return 5; @@ -727,7 +727,7 @@ eof: if (s->eof) { enum bio_status st = (s->error == ETIMEDOUT) ? BIO_TIMEOUT : BIO_ERROR; - return lbox_io_readline_ret(L, s, NULL, 0, st, 0); + return lbox_socket_readline_ret(L, s, NULL, 0, st, 0); } /* case #1: success, separator matched */ @@ -750,7 +750,7 @@ eof: if (s->eof) { * */ static int -lbox_io_bind(struct lua_State *L) +lbox_socket_bind(struct lua_State *L) { struct bio_socket *s = bio_checksocket(L, 1); const char *host = luaL_checkstring(L, 2); @@ -776,19 +776,17 @@ lbox_io_bind(struct lua_State *L) return 1; } -/* +/** * socket:listen() * * Marks the socket that it will be used to accept incoming * connection requests using socket:accept(). * - * Return: - * - * 1. ok: socket (self) - * 2. error: nil, status = "error", eno, estr + * @retval socket (self) on success + * @retval nil, status = "error", errno, error string */ static int -lbox_io_listen(struct lua_State *L) +lbox_socket_listen(struct lua_State *L) { struct bio_socket *s = bio_checkactivesocket(L, 1); bio_clearerr(s); @@ -805,11 +803,11 @@ lbox_io_listen(struct lua_State *L) * socket. * * 1. ok: socket (client), address, port - * 2. error: nil, nil, nil, status = "error", eno, estr - * 3. timeout: nil, nil, nil, status = "timeout", eno, estr + * 2. error: nil, status = "error", eno, estr + * 3. timeout: nil, status = "timeout", eno, estr */ static int -lbox_io_accept(struct lua_State *L) +lbox_socket_accept(struct lua_State *L) { struct bio_socket *s = bio_checkactivesocket(L, 1); double timeout = TIMEOUT_INFINITY; @@ -826,9 +824,7 @@ lbox_io_accept(struct lua_State *L) coio_init(&client->coio, fd); } @catch (SocketError *e) { /* case #2: error */ - lua_pushnil(L); - lua_pushnil(L); - return 2 + bio_pusherror(L, s, errno); + return bio_pusherror(L, s, errno); } /* get user host and port */ char hbuf[NI_MAXHOST]; @@ -838,9 +834,7 @@ lbox_io_accept(struct lua_State *L) sbuf, sizeof(sbuf), NI_NUMERICHOST|NI_NUMERICSERV); if (rc != 0) { /* case #2: error */ - lua_pushnil(L); - lua_pushnil(L); - return 2 + bio_pusherror(L, s, ERESOLVE); + return bio_pusherror(L, s, ERESOLVE); } /* push host and port */ lua_pushstring(L, hbuf); @@ -860,7 +854,7 @@ lbox_io_accept(struct lua_State *L) * 3. timeout: nil, status = "timeout", eno, estr */ static int -lbox_io_sendto(struct lua_State *L) +lbox_socket_sendto(struct lua_State *L) { struct bio_socket *s = bio_checksocket(L, 1); size_t buf_size = 0; @@ -907,13 +901,11 @@ lbox_io_sendto(struct lua_State *L) * Return: * * 1. ok: data, client_addr, client_port - * 2. error: data = "", client_addr = nil, client_port = nil, status = "error", - * eno, estr - * 3. timeout: data = "", client_addr = nil, client_port = nil, status = "timeout", - * eno, estr + * 2. error: data = "", status = "error", eno, estr + * 3. timeout: data = "", status = "timeout", eno, estr */ static int -lbox_io_recvfrom(struct lua_State *L) +lbox_socket_recvfrom(struct lua_State *L) { struct bio_socket *s = bio_checkactivesocket(L, 1); int buf_size = luaL_checkint(L, 2); @@ -962,31 +954,31 @@ lbox_io_recvfrom(struct lua_State *L) } void -tarantool_lua_io_init(struct lua_State *L) -{ - static const struct luaL_reg lbox_io_meta[] = { - {"__gc", lbox_io_close}, - {"__tostring", lbox_io_tostring}, - {"error", lbox_io_error}, - {"close", lbox_io_close}, - {"shutdown", lbox_io_shutdown}, - {"connect", lbox_io_connect}, - {"write", lbox_io_write}, - {"read", lbox_io_read}, - {"readline", lbox_io_readline}, - {"bind", lbox_io_bind}, - {"listen", lbox_io_listen}, - {"accept", lbox_io_accept}, - {"sendto", lbox_io_sendto}, - {"recvfrom", lbox_io_recvfrom}, +tarantool_lua_socket_init(struct lua_State *L) +{ + static const struct luaL_reg lbox_socket_meta[] = { + {"__gc", lbox_socket_close}, + {"__tostring", lbox_socket_tostring}, + {"error", lbox_socket_error}, + {"close", lbox_socket_close}, + {"shutdown", lbox_socket_shutdown}, + {"connect", lbox_socket_connect}, + {"write", lbox_socket_write}, + {"read", lbox_socket_read}, + {"readline", lbox_socket_readline}, + {"bind", lbox_socket_bind}, + {"listen", lbox_socket_listen}, + {"accept", lbox_socket_accept}, + {"sendto", lbox_socket_sendto}, + {"recvfrom", lbox_socket_recvfrom}, {NULL, NULL} }; - static const struct luaL_reg iolib[] = { - {"tcp", lbox_io_tcp}, - {"udp", lbox_io_udp}, + static const struct luaL_reg socketlib[] = { + {"tcp", lbox_socket_tcp}, + {"udp", lbox_socket_udp}, {NULL, NULL} }; - tarantool_lua_register_type(L, iolib_name, lbox_io_meta); - luaL_register(L, iolib_name, iolib); + tarantool_lua_register_type(L, socketlib_name, lbox_socket_meta); + luaL_register(L, socketlib_name, socketlib); lua_pop(L, 1); } diff --git a/test/box/lua.result b/test/box/lua.result index b6064e5f4ebd90cc6481997bc670e5b928bd7214..77fab6ea919ef47c01d41d8690cad03b60e768f5 100644 --- a/test/box/lua.result +++ b/test/box/lua.result @@ -15,33 +15,34 @@ lua for n in pairs(box) do print(' - box.', n) end - box.fiber - box.space - box.cfg + - box.on_reload_configuration - box.time64 - box.uuid - - box.select_limit + - box.ipc - box.delete - - box.on_reload_configuration - - box.replace - box.bless_space + - box.replace - box.counter + - box.auto_increment - box.time - box.select_range - box.insert - - box.auto_increment - box.update + - box.select_reverse_range - box.info - box.session - box.uuid_hex - - box.select_reverse_range + - box.select - box.slab - box.process - - box.select - box.dostring + - box.select_limit - box.stat - box.flags - box.unpack - - box.ipc - - box.index - box.pack + - box.index + - box.socket ... lua box.pack() --- diff --git a/test/box/lua_sockets.result b/test/box/socket.result similarity index 98% rename from test/box/lua_sockets.result rename to test/box/socket.result index 784ca229b8062fe106b5a4f823d329dd677238bc..ad6fbdf262bf5798f6622faa7e4cebf4d7c5219f 100644 --- a/test/box/lua_sockets.result +++ b/test/box/socket.result @@ -1,4 +1,4 @@ -lua s = box.io.udp() +lua s = box.socket.udp() --- ... lua type(s) @@ -8,7 +8,7 @@ lua type(s) lua s:close() --- ... -lua s = box.io.tcp() +lua s = box.socket.tcp() --- ... lua type(s) @@ -120,7 +120,7 @@ lua s:error() - 110 - Connection timed out ... -lua s = box.io.tcp() +lua s = box.socket.tcp() --- ... lua type(s:connect('127.0.0.1', '30303')) @@ -859,7 +859,7 @@ lua s:close() --- ... ping -lua s = box.io.udp() +lua s = box.socket.udp() --- ... lua type(s:sendto('ping', 'localhost', '30302')) @@ -879,7 +879,7 @@ lua s:read(4) lua s:close() --- ... -lua s = box.io.udp() +lua s = box.socket.udp() --- ... lua type(s:bind('localhost', '30301')) diff --git a/test/box/lua_sockets.test b/test/box/socket.test similarity index 97% rename from test/box/lua_sockets.test rename to test/box/socket.test index 60d47698907aa2eaececa55e7ceea691de07aca8..98e220f3d8a7eb94a15edac902a96930dd3ee5c3 100644 --- a/test/box/lua_sockets.test +++ b/test/box/socket.test @@ -2,16 +2,16 @@ import socket -#################### -# # -# box.io.tcp/udp() # -# # -#################### +######################## +# # +# box.socket.tcp/udp() # +# # +######################## -exec admin "lua s = box.io.udp()" +exec admin "lua s = box.socket.udp()" exec admin "lua type(s)" exec admin "lua s:close()" -exec admin "lua s = box.io.tcp()" +exec admin "lua s = box.socket.tcp()" exec admin "lua type(s)" ### socket:close() @@ -76,7 +76,7 @@ s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('localhost', 30303)) s.listen(1) -exec admin "lua s = box.io.tcp()" +exec admin "lua s = box.socket.tcp()" exec admin "lua type(s:connect('127.0.0.1', '30303'))" exec admin "lua s:write('ping')" exec admin "lua s:error()" @@ -471,7 +471,7 @@ s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('localhost', 30302)) # SOCK_DGRAM -exec admin "lua s = box.io.udp()" +exec admin "lua s = box.socket.udp()" exec admin "lua type(s:sendto('ping', 'localhost', '30302'))" exec admin "lua s:error()" @@ -489,7 +489,7 @@ exec admin "lua s:close()" # connect from test to echo server implemented in # stored procedure and do send/recv. # -exec admin "lua s = box.io.udp()" +exec admin "lua s = box.socket.udp()" exec admin "lua type(s:bind('localhost', '30301'))" exec admin "lua s:error()"