首页 > 解决方案 > 如何在同一wifi中连接其他PC上的网络服务器?

问题描述

我的 PC 上运行着 Http 服务器,我可以使用 localhost 或 192.168.1.69 与服务器通信。我在与 PC 相同的 wifi 中有一台平板电脑,当我执行 192.168.1.69:8080/hello 时,我没有得到任何响应。

我尝试在路由器上设置端口转发,将 .exe 添加到防火墙信任,还尝试使用带有端口号的公共 ip(打开路由器登录页面)。但他们没有帮助,

    public HttpServer(int port)
    {
        if (!HttpListener.IsSupported)
        {
            // Requires at least a Windows XP with Service Pack 2
            throw new NotSupportedException(
                "The Http Server cannot run on this operating system.");
        } // end if HttpListener is not supported

        _httpListener = new HttpListener();

        _httpListener.Prefixes.Add("http://localhost:" + port + "/");
        _httpListener.Prefixes.Add("http://192.168.1.69:" + port + "/");

        _resourceLocator = new Locator();

    } 

    public void Start()
    {
        if (!_httpListener.IsListening)
        {
            _httpListener.Start();
            _running = true;

            _connectionThread = new Thread(new ThreadStart(this.ConnectionThreadStart));
            _connectionThread.Start();
        } 
    }

标签: c#lanhttpserver

解决方案


推荐阅读