Echo server: Difference between revisions
Content added Content deleted
m (Added further explanation) |
m (Tidied Lua explanation) |
||
Line 1,168: | Line 1,168: | ||
=={{header|Lua}}== |
=={{header|Lua}}== |
||
{{libheader|LuaSocket}} |
{{libheader|LuaSocket}} |
||
This implementation doesn't rely on coroutines because they're an additional (often confusing) notion that could make the example needlessly hard to understand. Instead |
This implementation doesn't rely on coroutines because they're an additional (often confusing) notion that could make the example needlessly hard to understand. Instead it uses a table of not-quite-non-blocking socket client objects (they block for one microsecond), which is iterated over to check on whether each one has either a line to echo or an error to warrant deletion. |
||
<lang Lua>require("socket") |
<lang Lua>require("socket") |
||
Line 1,183: | Line 1,183: | ||
return err |
return err |
||
end |
end |
||
return |
return nil |
||
end |
end |
||