[英]Connecting to Python Server via C# Client
I/we've got a tiny problem here. 我/我们在这里遇到了一个小问题。 We are trying to connect to a server, written in python, with a client, written in C#, via TCP connection. 我们试图通过TCP连接连接到用python编写的服务器和用C#编写的客户端。
I'm capable of connecting to Port 80, but to none else. 我能够连接到80端口,但不能连接到其他端口。 Is there any big mistake we are looking at? 我们正在看是否有任何重大错误? Furthermore we tried running the server (python) on a usual PC as well as on a webspace. 此外,我们尝试在普通PC和网站空间上运行服务器(python)。
static void Main(string[] args)
{
TcpClient socket = new TcpClient();
socket.Connect("<my ip here>", 8585);
if(socket.Connected)
{
Console.WriteLine("connected!");
}
else
{
Console.WriteLine("connection failed!");
}
Console.ReadLine();
}
Server: Click here 服务器: 点击这里
Can you also ping the webspace including port 8686 like http://localhost:8686
? 你还能ping网页空间,包括端口8686,如http://localhost:8686
?
Maybe the webspace provider is blocking port 8686. 也许网站空间提供商正在阻止端口8686。
Try to bind the port of the python server to port 80. 尝试将python服务器的端口绑定到端口80。
Update : 更新 :
When the webspace does not allow binding to port 80, then try to make it open port 8686 or change the provider:) 当网站空间不允许绑定到端口80时,请尝试将其打开端口8686或更改提供程序:)
You can still try it on localhost. 你仍然可以在localhost上试试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.