c # Socket to solve the problem - because the target machine actively refused it, can not connect

About this problem much go into stand-alone, mainly on the solution of this problem appears servers and clients.

1. Check the firewall

Up to this problem, especially your service machines or buy various cloud offerings, such as Ali cloud is to add inbound and outbound firewall rules, Azure is there is a corresponding inbound and outbound configuration. The TCP and UDP port you use to open the corresponding. If that trouble can 1-65535 ports are open . Here in particular, says Azure will check unsafe behavior at your service machines on a regular basis, you may open the configuration back without authorization will remove all ports. Specific operation is not to say, a lot of online tutorials to add firewall rules.

2. Check machine service port is occupied. (It is not meaningful)

The second probability is very small problem, because your server program up time if the port is occupied or direct error. So if you get up, but no error, the basic problem is not occupied by the port, but just in case you can open cmd, use the "netstat -an" command to view the port number of activities to see if your server ports are being monitored.

3. The socket is bound ip issues

Most online demo wording is bound to "127.0.0.1" This is a very informal wording, because it is mostly single demo, no problem, but once on the exposed separately, so the formal wording It should be " your socket socket object .bind (new new IPEndPoint (IPAddress.Any, Port)); "

The 127.0.0.1 into IPAddress.Any the problem is solved.

Guess you like

Origin www.cnblogs.com/qwqwQAQ/p/11621993.html