c# - Connecting to myself using .NET sockets -


I am creating a server client application. I am able to connect to the application on the same network. For example, I can connect to 10.0.0.3 and 10.0.0.4 .

I am now trying to connect to my external IP and I receive:

System.Net.Sockets.SocketException (0x80004005) No connection can be made because the target machine has actively denied it.

  listen to = new socket (address.internetwork, socket type stream, protocol type. TCP); Write = new socket (Address Family.Inter Network, SocketType.Stream, ProtocolType.Tcp); End = new ippointpoint (ipadress purse (ip), 3212); Write.Connect (end);  

Is this a problem with my code or my router settings? Or that you can not connect with yourself ... though it does not understand that I can connect to 127.0.0.1 .

This is a common loopback error, because you are routing Internet NAT redirection when your external IP Your modem / router has been assigned ... not your computer, remember that your router can manage traffic for more than one device within a network under a single external IP, then this specific local connected device. One example is that your home network with 2 computers, one printer and 2 mobile devices is connected to all your networks via Wi-Fi, all will have a local IP address, which is possible through DHCP However, the external IP address is the same for all local devices because the external IP address is assigned to your router.

Always use a local IP address when you are connected to local network devices

edit

I wanted to keep this answer as simple as possible , But Scott's comment asked me to think again that it is always useful to add information that can help the community there.

Actually, you can actually set up port forwarding that allows your router to redirect traffic to a specified port in a specific device specified in your local network. This allows your device to be accessible from outside your network at that particular port, and you can easily take advantage of it to connect chairs inside your local network using your external IP address. Flip side is that not all router / modem port supports forwarding, so you have to specify the manual of your modem and check whether it is supported or not.

However, if you want to set it only for the reason that you want to connect the device to your local network using external IP, then I will do this and use the internal IP address. Do not advise, you really do not want to go through security risks that are involved in exposing your local appliances on the Internet. You can easily set strict firewall rules for outsiders and protect them comfortably in your local network.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -