我正在尝试了解套接字类,并且我正在使用以下示例来实现服务器示例
local server = assert(socket.bind("*", 0))
-- find out which port the OS chose for us
local ip, port = server:getsockname()
-- print a message informing what's up
print("Please telnet to localhost on IP [" ..ip.. "] and port [" .. port .. "]")
print("After connecting, you have 10s to enter a line to be echoed")
-- loop forever waiting for clients
while true do
-- wait for a connection from any client
local client = server:accept()
-- make sure we don't block waiting for this client's line
client:settimeout(10)
-- receive the line
local line, err = client:receive()
-- if there was no error, send it back to the client
if not err then
client:send(line .. "\n")
end
-- done with client, close the object
client:close()
end
但现在的问题是,我如何通过 lua 远程登录例如地址 localhost:8080?
编辑:我忘了说点什么,我什至不能在 cmd 上远程登录。当我键入命令时:
远程登录 ip 端口
我发送消息后它总是说“连接丢失”。我究竟做错了什么?