Is it possible to get main server system's(which is connected to LAN) ip address from client system using java?
If yes, how can i do using code?
Generally it is impossible whether using java or any other programming language. This is the reason that LANs exist. The internal IP address is not sent outside the local network and therefore cannot be detected.
However if client and server are developed especially to complete this task to can send the IP on application level. For example to send the IP as a HTTP header if connection is done over HTTP.
Related
I have created project which has two components as Desktop client and web.
web server is communicating to the my another program which i run as client on other systems.
After connecting those clients communication is happening in network as all IP's within network are reachable.
However, when i deployed web app on public IP now i am not able to connect the clients as the local IP's of those clients are not reachable by server.
How can i achieve this communication between local IP to public and vice versa?
There are multiple ways to achieve this.
Anyways, if you want the service to be reachable publically then you´ll probalby want to forward the Port to the machine running the service.
Also, make sure the Firewall allows connections to this port.
Since you´re talking about Web-Apps it´s probably HTTP, Port 80 TCP, or HTTPS, the encrypted version of HTTP running on port 443 TCP.
To explain it, your ISP gives you one public IP address.
Since you probably have multiple devices using internet, they all appear in the internet as the one IP address your provider gave you.
Whenever you send something out your router will remember where you tried to connect and if a response comes in your router knows which device to send the response to.
Now, since you want someone to connect to you, there was no request so your router does not know where to put the packet and simply blocks it.
In most routers you can configure something usually called NAT or Port Forwarding. You simply specify that communication on Port 80 or 443 should be routed to the internal IP. It has one of the following formats:
192.168.0.1 - 192.168.255.254
172.16.XXX.XXX - 172.31.255.254
10.0.0.0 – 10.255.255.254
I'm doing a project, I have a server, a client (C #), a client (Android java). I can connect to the server on the local network and use an external ip from the client C #, but from the Java client I can connect only by Wifi. The server on the router port forwarding, I have a static ip address. Help please what's the problem?
From the info you provided, there is nothing wrong.
For your C# client, you can connect it from local network (i assume 192.168.x.x)
and
For your java client, using wifi means local network (also i assumed 192.168.x.x)
so it means that it works well with local network.
So now the main problem is, is your server really online to internet
Please check the following:
Is your server accessible via any api testing tools, such as RESTFUL AND SOAPUI using external ip address.
Is you android client really online when not using a local network, or you can access it through external ip address.
Im using TCP/IP sockets in java to try and create a client-server application. The program works fine when run locally and also over the local area network, but when I use the internet IP address the clients connection is refused.
I used this website to get my IP address and have added a firewall entry to unblock the port im using (port 4445).
I am almost certain the problem lies in some sort of security measure that is blocking the port. Does it matter that I'm running the client and server on the same PC but using the IP address from the previously mentioned website?
If I could get a list of ways to test the port is in fact open, or a list of things to try in order to get my program running, that would be great!
That website may very likely give you the IP address of the gateway through which your PC is connecting to the internet, and if the gateway is out of your control (which is most of the cases as far as I know) there's nothing you can do to use that IP address to test your program. Here's some advice:
Try http://aws.amazon.com, once registered you have one-year free access to a micro-server (which can be accessed publicly through DNS/Elastic IP.)
If your PC have a public IP address, you don't need that website to find out what it is. Just check your network adapter control panel.
Where is the server has been located? If your server is located in some commercial hosting, there is possibility that the ports you use are blocked. Also if you use modem with router or just router in your local network you should check nat table.
I am working on a project for androids/computers have p2p talking, and we are experimenting with hole-punching in order to get through the wifi's firewall. However the wifi needs to UDP packet needs to look like it is coming from the same machine that the initial Packet was sent to. Using netcat (and choosing which port to send from) from the same machine we can send information back into the computer. However if we are coming from a different device we need to appear as though we have the same IP address, and port. I was wondering if you can easily specify the Sending IP and Port of the packet? I was thinking of using DatagramPacket, but didn't find any methods that would work.
You can't do that from within Java. You can do it with Java plus one of the several Jpcaps in existence, but be aware it's a JNI library with all the risks that entails.
I am learning inter-process communication. I want to create server that can listen to client distributed over actual local area network. I have IP address as well as symbolic name of those machines. I can implement sever and client on single machine but I don't know how to do same on different machines on network.
Can anyone direct me to appropriate resources or tell me how to do it ?
Thanks
It's the same. The only difference is that you need to use the server ip address instead of the local address when you connect the client socket.