table getsockinfo()
| 283 | |
| 284 | // table getsockinfo() |
| 285 | static int l_socket_getsockinfo(lua_State *L) { |
| 286 | char buf[256]; |
| 287 | short port = 0; |
| 288 | p_tcp tcp = (p_tcp) checktype(L, 1, SOCKET_ANY); |
| 289 | if (socket_get_info(&tcp->sock, &port, buf, 256) == SUCCESS) { |
| 290 | lua_newtable(L); // t |
| 291 | lua_pushstring(L, "host"); // t, "host" |
| 292 | lua_pushstring(L, buf); // t, "host", buf |
| 293 | lua_rawset(L, -3); // t |
| 294 | lua_pushstring(L, "port"); // t, "port" |
| 295 | lua_pushnumber(L, port); // t, "port", port |
| 296 | lua_rawset(L, -3); // t |
| 297 | return 1; |
| 298 | } |
| 299 | return 0; |
| 300 | } |
| 301 | |
| 302 | //////////////////////////////////////////////////////////////////////////////// |
| 303 | // Server |
nothing calls this directly
no test coverage detected