Hi, I've been working on a small telnet program, ran into a few bumps along the way.
Here's my code:
local component = require("component")
local internet = require("internet")
local host = "gcomm.com:23"
-- try to connect to server.
local sock, reason = internet.open(host)
if not sock then
io.stderr:write(reason .. "\n")
return
end
sock:setTimeout(0.05)
repeat
local ok, line = pcall(sock.read, sock)
if ok then
if not line then
print("Connection lost.")
sock:close()
sock = nil
return false
end
print(line)
end
until not sock
As you can see it simply outputs messages directly to the screen (Don't know what this host is, seems to be some type of message board or something, found it on Google )
In ComputerCraft I would run 2 functions in parallel one to listen and one to handle drawing and everything else (user input) but I'm not to sure how the same thing would be accomplished in OpenComputers.
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Hi, I've been working on a small telnet program, ran into a few bumps along the way.
Here's my code:
As you can see it simply outputs messages directly to the screen (Don't know what this host is, seems to be some type of message board or something, found it on Google )
In ComputerCraft I would run 2 functions in parallel one to listen and one to handle drawing and everything else (user input) but I'm not to sure how the same thing would be accomplished in OpenComputers.
Any help would be much appreciated.
Link to post
Share on other sites