Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux虚拟机中服务开启后,在用Windows系统中Telnet连接不上 #1706

Open
mishuawu opened this issue Feb 22, 2023 · 1 comment

Comments

@mishuawu
Copy link

Linux虚拟机中的服务端代码如下:

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虚拟机中的控制台通过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: 连接失败


不知道为什么出现这种情况,也不知道怎么解决,希望能得到帮助。。

@hanxi
Copy link
Contributor

hanxi commented Feb 22, 2023

虚拟机网络配置问题?虚拟机设置成桥接模式应该就可以用虚拟机的ip访问了,或者nat模式配好转发端口就可以用主机ip访问。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants