You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
local skynet = require "skynet"
local socket = require "skynet.socket"
local db = nil;
skynet.start(function ()
local listenfd = socket.listen("0.0.0.0", 8888);
socket.start(listenfd, connect);
end)
function connect(fd, addr)
print("cocos_listned");
socket.start(fd);
while true do
local readdata = socket.read(fd);
if (readdata) then
print("readdata = "..readdata);
end
end
end
Linux虚拟机中的服务端代码如下:
local skynet = require "skynet"
local socket = require "skynet.socket"
local db = nil;
skynet.start(function ()
end)
function connect(fd, addr)
print("cocos_listned");
socket.start(fd);
while true do
local readdata = socket.read(fd);
if (readdata) then
print("readdata = "..readdata);
end
end
end
然后在Linux虚拟机中的控制台通过skynet运行
[root@localhost skynet]# ./skynet examples/Pconfig
[:01000002] LAUNCH snlua bootstrap
[:01000003] LAUNCH snlua launcher
[:01000004] LAUNCH snlua cmaster
[:01000004] master listen socket 0.0.0.0:2013
[:01000005] LAUNCH snlua cslave
[:01000005] slave connect to master 127.0.0.1:2013
[:01000004] connect from 127.0.0.1:56838 4
[:01000006] LAUNCH harbor 1 16777221
[:01000004] Harbor 1 (fd=4) report 127.0.0.1:2526
[:01000005] Waiting for 0 harbors
[:01000005] Shakehand ready
[:01000007] LAUNCH snlua datacenterd
[:01000008] LAUNCH snlua service_mgr
[:01000009] LAUNCH snlua 2_cocos_test
[:01000002] KILL self
在Linux虚拟机中通过控制台 telnet链接
[root@localhost ~]# telnet 192.168.122.1 8888
Trying 192.168.122.1...
Connected to 192.168.122.1.
Escape character is '^]'.
这里可以链接成功
在Windows系统通过控制台用telnet链接
C:\Users\Lenovo>telnet 192.168.122.1 8888
正在连接192.168.122.1...无法打开到主机的连接。 在端口 8888: 连接失败
不知道为什么出现这种情况,也不知道怎么解决,希望能得到帮助。。
The text was updated successfully, but these errors were encountered: