require
#10
Is there anything in particular in LFS that you think the cFile API doesn't provide? I'd like to think that we already cover that one in MCS.

LuaSocket is a natural choice; however it doesn't play too well with MCS architecture, because it uses blocking IO, and MCS plugins cannot afford to block - they'd block the entire server. We need to implement our own socket library, built on asynchronous events, something like this:
-- Client example:
g_Socket = cSocket()
local function OnConnect(a_Socket)
  a_Socket.Send("hello")
end
local function OnReceiveData(a_Socket, a_Data)
  LOGINFO("Received: " .. a_Data)
end
local function OnDisconnect(a_Socket)
  LOGINFO("Socket disconnected")
end
g_Socket:Connect("hostname", port, OnConnect, OnReceiveData, OnDisconnect)

-- Server example:
g_Socket = cSocket()
-- TODO: Define the handler functions
g_Socket:Bind("LocalIP", port, OnClientConnected, OnClientReceiveData, OnClientDisconnect)

As for threading, I was considering various alternatives, this one looks really good, we can make a similar interface in MCS. Instead of giving it a string of code to run, though, I would prefer giving it an entire disk file, how about that? Of course, the child thread won't have access to most MCS API, I think only the cFile API is safe enough, maybe cBlockArea (but without cWorld). It will be possible to "TryJoin" a thread that will join the thread if it has ended or return no value if the thread is still running.
Reply
Thanks given by:


Messages In This Thread
require - by NiLSPACE - 01-19-2014, 06:08 AM
RE: require - by xoft - 01-19-2014, 06:10 AM
RE: require - by NiLSPACE - 01-19-2014, 06:26 AM
RE: require - by xoft - 01-19-2014, 06:33 AM
RE: require - by NiLSPACE - 01-19-2014, 06:58 PM
RE: require - by xoft - 01-19-2014, 10:41 PM
RE: require - by NiLSPACE - 01-19-2014, 10:58 PM
RE: require - by xoft - 01-19-2014, 11:51 PM
RE: require - by NiLSPACE - 01-19-2014, 11:54 PM
RE: require - by xoft - 01-20-2014, 12:14 AM
RE: require - by NiLSPACE - 01-20-2014, 12:25 AM



Users browsing this thread: 2 Guest(s)