"Full ip" means global ip(I have a static) + local ip(192.168.0.xxx - address in my local network).
I wrote simple Server and Client application using java.net.ServerSocket and java.net.Socket relatively.
On the localhost it working good. But I'm interesting in running server app on the computer in my local network(router) and connecting to it from everywhere using Client app.
Connection is established as follows:
Socket socket = new Socket(IP, PORT);
I tried my absolute static ip(but it's router ip), router ip + local ip(192.168.0.100) it's all not working.
How can I specify the full path to my "server" in router local network?
I think you misunderstood IP addresses.
Any IP address is just a SINGLE IP address. There is no such thing as a "relative" IP address, like you have a relative path in a file system.
Suppose you have an externally-visible router IP of, say 136.23.75.30. You then have a local subnet of 192.168.x.y, where your own host has an address of 192.168.1.100 and your router has address of 192.168.1.1 .
In that situation, when you connect to your host from inside your subnet, you can specify the host's address on the subnet, 192.168.1.100 .
However, when you connect from the Internet at-large, the only IP you can connect to is you router's external IP, as provided by your ISP. In our example it's 136.23.75.30 . Any attempt to connect to 192.168.1.100 from any location outside of your own subnet will go to a wrong host or nowhere at all.
How can you accomplish what you need? The secret is in your router's configuration. You need to set the router up for port forwarding. Basically, your router will take the incoming connection on certain port (let's say 8888) and turn that connection into the connection to your host, 192, 168.1.100 on, for example, the same port, 8888.
In other words, the outside world thinks that it connects to 136.23.75.30, while in reality the router makes sure that 192.168.1.100 is responding.
Assuming this is a home setup, you need to get to you router's admin screen. You can do it by putting "http://192.168.1.1" into your browser's address bar. After providing suitable authentication (usually printed on the router's back) you need to find some sort of advanced setup tab, and look for "Port Forwarding". There you usually enter the target address, 192.168.1.100, and the source and target port (let's say both are 8888).
Related
hello everyone i'm making an application that uses DatagramSocket to transmit data between Pc and android Phone it works when i use a local ip Address but when i use ddns from no-ip or my public ip address it didn't i work i get this error message
DatagramSocket serverSocket = new DatagramSocket(port,InetAddress.getByName("XXXXX.ddns.net"));
i got this error message :
java.net.BindException: Cannot assign requested address: Cannot bind
plz help me how can i establish a connection between two machines using no-ip ddns instead of my local ip address
You can only bind an addresses that are configured on network interfaces on the device you use. I don't know your home network setup but most likely your public IP address is configured on the router/modem you use to connect to the internet so this simply will not work.
Your router may have port forwarding feature where it sends packets sent to a specific port to a specific IP address in your home network. You would have to configure a static IP address on the device and set up port forwarding to that address.
I have to build a server/client chat room in java as a school project, and I want to know if I can connect to that server from the world network (not local network) using the IP address and ports (I wanted to host it but I realized too late that I should have built a web app not a desktop one). My app is using Transmission Content Protocol(TCP) sockets. I have tried to connect to the app by using the public IP and the port that I have opened in firewall. I can post the code if needed. Thanks in advance
If your networks firewall settings let you do it, of course you can connect.
Now, your computer has an internal ip address, which is like 192.168.xxx.xxx and your router has an external ip address which is unique.
Set up your router to forward connections. Steps to do it may change for each router but the point is to forward all connections coming to this router with a port number you have declared, to a internal ip address and a port number.
In your client side, your connection statement will have your external ip adress and the port number you have written in your router settings. In your server side, it will listen your internal ip address and the port number your router forwards to.
To be clear;
Client ---"xx.xx.xx.xx:9999"---> Router ---"192.168.xx.xx:8888"---> Server
As you see above, the router forwards all the connections coming to 9999. port, to 192.168.xx.xx address and 8888. port.
I have absolutely no idea what I am doing wrong. About a month ago, I set up my router to work with a server/socket connection in Java. I just moved back to my apartment, and am using a different router with a different ip in a different area.
Connecting to localhost (as the default) with my ServerSocket, and then connecting to the ip I get from whatsmyip.org as the hostname for the client socket, shouldn't I be able to connect?
The server and client are running on the same computer, and if I switch the hostname of the client to localhost, the connection works perfectly. I have a port forwarding set up to my computer's ip address that the router gets for me (not from whatsmyip.org) to port 1640, which is what I was using back at my old place where it was working. What am I doing wrong here?
EDIT 1: I am using DynDNS.com to set up a hostname URL that links to my computer's IP, which I then have all of the clients connect to. The client program can be on any computer anywhere. Before I switch routers, this was working perfectly. I was using the Dynamic DNS feature of the router using my DynDNS account, which was set up on my old router, and my new one. So basically, I should just use my old router?
Some routers will not route the external IP while you are on the internal network. I had a router which was like this. Try connecting from an external location (have a friend try, connect to a remote server and connect back in, or use a device connected to 3G wireless etc).
But im not sure from your question if you actually want to connect from the outside. If you dont, there is no need to creating the port forward (in fact you are just making your server visible to the world unnecessarily). Use the local address of your machine (192.168.x.x / 10.1.1.* etc depending on your router) from any machine within your LAN.
I have fully developed a chat room for multiple clients with multi-threaded server which does the job, however only on my local machine. I want to go beyond this, and make this chat room to be working over the internet. So far I have made the port forwarding on my router for TCP protocol to route to my local IP address, however this didn't solve the problem and I still can't connect the client, even on my own local network. What other steps should I follow to get my chat room working on my own local network and then the internet?
try disable (windows) firewall ?
So my friend the basic rule for make anything to work over internet is to do Port forwarding or in simple way you can say that to open your server for the public network. For that you need to make sure that the routing path is complete from internet machines to your desktop. For this to work you need to open the port for which you need to access your machine from firewall settings, and also ensuring that trafic is routed from your public IP address to the server's IP as your server will be private under some router or ISP.
Way to do that:
You need to configure your home network i.e router setting. So in your router, configure the port you want the communication to happen(say port 5443).
In your router, configure a port-forward for the port 5443 to the internal IP address of your actual server, also to port 5443.
Reference: https://www.noip.com/support/knowledgebase/general-port-forwarding-guide/
On your server(your Desktop Machine) ensure that your firewall settings for port 5443 is on and set to allow rather than block.
I am having an issue with my socket connection. When I replace my no-ip address with "localhost" it works fine, but as soon as I put in my no-ip address, it cannot connect. I have forwarded the port from my router (port 12345 TCP and UDP forwarded to my local IP address 192.168.1.116). I don't understand why it would work with "localhost" but not with "myaddress.no-ip.org". It was of my understanding all you had to do was forward the port on your router to your local IP address.
You can't forward your internal IP address. A 192.168.x.x address is only usable on your internal network. You need to forward you external address. http://whatismyipaddress.com/
OK, here is the most probable solution to the problem. The Modem that I have from Time Warner (RoadRunner) has a built in modem. I have to get them to bridge the connection so it passes through the router. My router was looking for something to come in on port 12345 so it could direct it to my computer. The problem was that TWCs router wasn't forwarding it to my router. After bridging the connection, it should just pass through the modem to my router.