Tcplistener问题+在C#中重启服务器 [英] Tcplistener problem+restart the server in C#
问题描述
好吧所以我有一个问题,就像它的工作(在ipv4地址和本地地址):
ok so i have a problem where like that its working(on ipv4 address and local address):
IPAddress ipaLocal = ipAddress;
tlsClient = new TcpListener(1986);
并且喜欢它不能处理ipv4地址:
and like that its not working on ipv4 address:
int port = 1986;
IPAddress ipaLocal = ipAddress;
tlsClient = new TcpListener(ipaLocal,port);
因为它不假设使用ipv4地址而且只有本地地址?
和另一件事是,我做的是你可以关闭你的服务器并重新启动到客户端而不关闭应用程序,但有一个错误,其中说:只允许使用每个套接字地址,我检查了所有代码和发现什么都没有打开。
感谢您的时间和帮助!!
代码: [C#]聊天服务器 - Pastebin.com [ ^ ]
基于我在互联网上找到的聊天内容。
我尝试了什么:
http://www.codeproject.com/Questions/72635/TCPListener-Stay-Connected-or-Connect-on-Demand
its because its not suppose to work with ipv4 address and with only local address?
and another thing is that i made is that you can close your server and relisten to clients without close the app but there is an error where its says: "only usage of each socket address is allowed", i checked in all the code and found nothing that have been left open.
thank for your time and help!!
the code:[C#] chat server - Pastebin.com[^]
its based on a chat that i found on the internet.
What I have tried:
http://www.codeproject.com/Questions/72635/TCPListener-Stay-Connected-or-Connect-on-Demand
推荐答案
只有本地地址:
only local address:
var tcpListener = new TcpListener(IPAddress.Parse("127.0.0.1"), 1986);
tcpListener.Start();
或处理任何IPv4地址:
or working on any IPv4 address:
var tcpListener = new TcpListener(IPAddress.Any, 1986);
tcpListener.Start();
这篇关于Tcplistener问题+在C#中重启服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!