我一直在谷歌搜索一段时间,似乎没有解决我在这里遇到的这个问题的提议。
我使用 LuaSocket 作为连接到我创建的外部服务器的简单方法,并且能够成功连接到它并发送信号。
但是,当我稍后尝试发送第二条消息时,即使我仍然连接到套接字,外部服务器似乎也没有收到该消息。
socket = require("socket")
host, port = ip, port
tcp = assert(socket.tcp())
tcp:settimeout( 0 )
tcp:connect(host, port);
msg = {
["status"]="connect",
["usrName"]=username
}
msg = Json.Encode(msg)
tcp:send(msg); -- This message, the server received this message.
-- Later in my code, I attempt to send another message.
msg = {
["status"]="anotherMessage",
["usrName"]=username
};
msg = Json.Encode(msg)
tcp:send(msg); -- This message is not sending, even though i'm still connected.