我刚刚在这上面花了两天时间。这是在游戏引擎 Unity3D 中运行的,但这不应该有所作为。这两行总是失败:
TcpClient client = new TcpClient();
client.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 15219));
我得到的错误是:
System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it.
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP, Boolean requireSocketPolicy) [0x00000] in <filename unknown>:0
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0
at System.Net.Sockets.TcpClient.Connect (System.Net.IPEndPoint remote_end_point) [0x00000] in <filename unknown>:0
at StreamIn.Connect (System.String server, System.String message) [0x00011] in C:\XXX\StreamIn.cs:41
UnityEngine.Debug:Log(Object)
StreamIn:uPrint(String) (at Assets/StreamIn.cs:27)
StreamIn:Connect(String, String) (at Assets/StreamIn.cs:77)
StreamIn:Start() (at Assets/StreamIn.cs:18)
我已经尝试了一切,包括更改我的防火墙设置和禁用防火墙。
我收到与虚拟 IP 地址相同的错误。
如果我尝试使用 port80
而不是15219
, Unity 编辑器会冻结。(我确实有一个 Web 服务器正在运行。)
我错过了一些明显的东西吗?还是不明显?