Lua Socket: Difference between revisions
From Spring
Jump to navigationJump to search
| Line 42: | Line 42: | ||
*most lua scripts from luasocket won't work as they are blocking! rewriting them non-blocking is required! (should be in most cases few work, as parsing stuff can be reused) | *most lua scripts from luasocket won't work as they are blocking! rewriting them non-blocking is required! (should be in most cases few work, as parsing stuff can be reused) | ||
*udp sendto isn't checked, only binding the udp-socket | *udp sendto isn't checked, only binding the udp-socket | ||
*config file should be better protected, see https://github.com/spring/spring/blob/develop/rts/System/Config/ConfigHandler.cpp#L289 + https://github.com/spring/spring/commit/948d6fb9d1c95b99b5cc7929cf3e0de0f9d6d93e maybe just locking the file is best?! | *config file should be better protected, see https://github.com/spring/spring/blob/develop/rts/System/Config/ConfigHandler.cpp#L289 + https://github.com/spring/spring/commit/948d6fb9d1c95b99b5cc7929cf3e0de0f9d6d93e maybe just locking the file is best?! see also http://springrts.com/mantis/view.php?id=2891 (private report) | ||
==documentation== | ==documentation== | ||
Revision as of 01:22, 30 January 2012
LuaSocket is a development branch of spring:
see https://github.com/spring/spring/tree/luasocket
config settings
All LuaSocket related config is readonly for LuaWidgets. They can be only changed through unitsync.
| LuaSocketEnabled = 1 | Default is 0 means, all Socket functions are disabled |
| TCPAllowConnect | allow TCP-connections to the listed hosts, for example: "springrts.com:80 springfiles.com:80" |
| TCPAllowListen | Server TCP-sockets are allowed on this port, for example: "localhost:1234 0.0.0.0:12345" |
| UDPAllowConnect | see TCPAllowConnect |
| UDPAllowConnect | see TCPAllowListen |
example code
see https://github.com/spring/spring/blob/luasocket/cont/examples/Widgets/luasocket.lua
Notes / known issues / TODO
- dns resolving is blocking
- allow rules have exactly match the host:port in script. currently its not possible to use host:port in a lua widget and use the resolved hostname for connecting (and vice versa) (simple workaround, add both as rule)
- socket=require("socket") is needed
- most lua scripts from luasocket won't work as they are blocking! rewriting them non-blocking is required! (should be in most cases few work, as parsing stuff can be reused)
- udp sendto isn't checked, only binding the udp-socket
- config file should be better protected, see https://github.com/spring/spring/blob/develop/rts/System/Config/ConfigHandler.cpp#L289 + https://github.com/spring/spring/commit/948d6fb9d1c95b99b5cc7929cf3e0de0f9d6d93e maybe just locking the file is best?! see also http://springrts.com/mantis/view.php?id=2891 (private report)