c# - 如何在同一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();
}
}
解决方案
推荐阅读
- javascript - 如何阻止它过度写入数据并将其添加到谷歌表格的最后一行
- swift - Swift iOS14 DatePicker 文本对齐
- c - 块是语句吗?
- java - 将 Scanner 对象作为构造函数参数传递给 UserInterface 类
- apache-kafka - 在 Azure CosmosDB SQL API 和 Google Bigquery 之间建立连接
- java - 使用 jacoco 离线检测使用 gradle 进行的每个测试的覆盖率 - java.lang.IllegalStateException: JaCoCo 代理未启动
- python - Python Sudoku Solver 进入无限循环,如何限制函数内的循环数量?
- python - 什么是“|” Django中的角色叫什么?
- c - 在C中设置新值以完成二维数组的行
- python - 如何在 django 模板中计算我的关注者?