Name: Anonymous 2015-02-10 0:47
In the spirit of wanting to see more programs on this board, I am posting this programlet. Its the beginnings of a server so I can talk to my universe LispM program as though its a BBS through a terminal program like putty.
Please post your programs as also well too mutually also together. I would like to see them. If they are graphical or audioful or gameful or simulationful programs are preferred, but of course, post any program.
Don't forget to comment, rate and subscribe.
WISHFUL THINKING
Please post your programs as also well too mutually also together. I would like to see them. If they are graphical or audioful or gameful or simulationful programs are preferred, but of course, post any program.
Don't forget to comment, rate and subscribe.
WISHFUL THINKING
function svrRunLuaPromptServer(sck)
local s = svrReceive(sck)
if s ~= "" then
luaCall(s)
local err = getErrorText()
if err ~= "" then
svrSend(err, sck)
clearError()
end
-- svrSend("Ready.\n")
--svrSend("\n> ")
svrSend("> ", sck)
end
end
function svrRunEchoServer(sck)
-- echo server
local s = svrReceive(sck)
if s~="" then
clearTrace()
for i=1,#s,1 do
print(string.byte(s,i))
end
end
svrSend(s, sck)
end
function initServer()
svrStart()
print("Server started")
coroutine.yield()
print("Waiting for terminal client...")
repeat
sck1 = svrAccept()
coroutine.yield()
until svrIsValidSocket(sck1)
print("Terminal client connected.")
svrSend("You are the lua prompt terminal\n> ", sck1)
coroutine.yield()
print("Waiting for echo client...")
repeat
sck2 = svrAccept()
coroutine.yield()
until svrIsValidSocket(sck2)
print("Echo client connected.")
svrSend("You are the echo terminal", sck2)
end
function restartServer()
initServerRoutine = coroutine.create(initServer)
coroutine.resume(initServerRoutine)
end
if initServerRoutine == nil then
restartServer()
end
function update()
if coroutine.status(initServerRoutine) ~= "dead" then
coroutine.resume(initServerRoutine)
else
svrRunLuaPromptServer(sck1)
svrRunEchoServer(sck2)
end
end