[英]What IP should I use to host my chat server?
I made chat server in C# using 我使用C#制作了聊天服务器
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.TCP);
s.Bind(IPAddress.Parse(theIP),thePort);
But then I am getting a 但是后来我得到了
"SocketException was unhandled, The requested address is not valid in its context" “未处理SocketException,请求的地址在其上下文中无效”
How do I look for the correct IP to use? 我如何寻找要使用的正确IP? cmd ipconfig IPv4Address? cmd ipconfig IPv4Address? Because that IP (I believe) is for the internal IP. 因为该IP(我相信)是用于内部IP的。 I want the server IP to be an external IP address that is accessible from outside my network 我希望服务器IP是可以从网络外部访问的外部IP地址
You need to create a static path (sometimes called port forwarding) in your router binding one of your external IP/ports to an internal address and the port needed for your chat server. 您需要在路由器中创建一条静态路径(有时称为端口转发),以将您的外部IP /端口之一绑定到内部地址以及聊天服务器所需的端口。 You will then reference your internal IP address, on your network, in your code. 然后,您将在网络中的代码中引用内部IP地址。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.