Accessing Remote PC in a different network with IP Address & Gateway
Is it possible to access remote PC in a different network with my Java Application ? How can I achieve the same ? Please give me some suggestions.
Thanks !
Re: Accessing Remote PC in a different network with IP Address & Gateway
rameshiit19
what you mean access remote PC? Access a file or DB? Or kinda of telnet? And it's depending on your Java skill. JMS (Java Message Services), Socket-Socket communication.
JMS: A JMS listening app runs on both PC (remote and local) and waits for a JMS message that can be an access to a file and replies via JMS message back to the requester. In this case you have a peer-to-peer communication. JMS is very versatile. More: Java Message Service (JMS)
Socket-Socket: This technique is wide-used. It's Client-Server technique.
Re: Accessing Remote PC in a different network with IP Address & Gateway
I meant Remote PC as PC which is in some other network. Both PCs are connected only through internet and I want to know whether it is possible to access that remote PC & make some processes / tasks there and get back the response. I am new to Java Networking and I want to analyse the possibility for the same before developing the same.
Thank you
Re: Accessing Remote PC in a different network with IP Address & Gateway
Quote:
Originally Posted by
rameshiit19
I meant Remote PC as PC which is in some other network. Both PCs are connected only through internet and I want to know whether it is possible to access that remote PC & make some processes / tasks there and get back the response. I am new to Java Networking and I want to analyse the possibility for the same before developing the same.
Thank you
You can pick the simple examples I posted for Sourparno'd thread RMI Interface server. It's the Client-server technique:
Server is the Whistleblower that sends every client's request a reply "Free Port = nnnn"
Client is the WhistleListerner that quests for the unused port from Whistleblower
Over Internet is a bit delicate because you must know the IP of your remote PC and this IP must be static which is not usually the case. Your Internet Service Provider ISP gives you normally a dynamic IP and that could change anytime (without a notice:mad:)
Re: Accessing Remote PC in a different network with IP Address & Gateway
I have referred Sourparno'd thread RMI Interface server. It was very useful . I am able to find out available sockets in same LAN but I am unable to ping the IP of remote PC , which is there in different network.I am getting error as request timed Out .
What are the possibilities by which I can access it ?
Re: Accessing Remote PC in a different network with IP Address & Gateway
Quote:
Originally Posted by
rameshiit19
I have referred Sourparno'd thread RMI Interface server. It was very useful . I am able to find out available sockets in same LAN but I am unable to ping the IP of remote PC , which is there in different network.I am getting error as request timed Out .
What are the possibilities by which I can access it ?
On a physical different network you have to know the Gateway or Router IP of this network then you can "ping" it. For the Server and its Clients there's only one virtual network where every participant has an unique IP (i.e. Internet Address). Here you should distinguish the internal IP and the external IP. The local IP or the internal IP represents the IP of every PC within your LAN. And the Gateway or Router of this LAN to the Internet or to other LAN has its own IP which is the external IP. This external IP is normally set by your Administrator. So, if you want your Client of LAN_1 accesses a server on LAN_2 you have to know the Gateway IP of LAN_2. Now think a bit more global: LAN_2 is the Internet...and the external IP is assigned by your Internet Provider. You can see your external IP here What Is My IP Address? Lookup IP, Hide IP, Change IP, Trace IP and more...
Re: Accessing Remote PC in a different network with IP Address & Gateway
Thank you for the detailed explanation .I have tried to ping my own Public IP address shown in What Is My IP Address? Lookup IP, Hide IP, Change IP, Trace IP and more... but I am getting error as "Request Timed Out" . I have also tried to ping the Public IP of remote PC in a different network , but I am getting the error as "Request Timed Out" .
How can I access / ping the remote PC with it's public IP ?
Re: Accessing Remote PC in a different network with IP Address & Gateway
Quote:
Originally Posted by
rameshiit19
Thank you for the detailed explanation .I have tried to ping my own Public IP address shown in
What Is My IP Address? Lookup IP, Hide IP, Change IP, Trace IP and more... but I am getting error as "Request Timed Out" . I have also tried to ping the Public IP of remote PC in a different network , but I am getting the error as "Request Timed Out" .
How can I access / ping the remote PC with it's public IP ?
Hey...how you ping this site? With the command "ping whatismyipaddress.com"? Well, not every site reply a ping. If you want to ping a certain IP you have to open a socket to this site and see if you're able to do it. Here is an example:
Code java:
import java.net.*;
public class PingIP {
public static void main(String[] args) {
if (args.length != 1) {
System.out.println("Usage: java PingIP IP/name");
System.exit(0);
}
try {
Socket soc = new Socket(args[0], 80);
soc.close();
System.out.println("IP/name="+args[0]+" exists...");
} catch (Exception e) {
System.out.println("Troubles with:"+args[0]);
}
}
}
then on a cmd-window:
D:\Test>java PingIP whatismyipaddress.com
IP/name=whatismyipaddress.com exists...
D:\Test>
Re: Accessing Remote PC in a different network with IP Address & Gateway
...and with this little program you can ping your own Internet IP
2 Attachment(s)
Re: Accessing Remote PC in a different network with IP Address & Gateway
I have tried pinging the Public IP , Localhost (127.0.0.1) and whats my IP Address but I am getting errors . I have added e.printStackTrace(); in catch block of the Program provided by you. I have attached the Output screenshot for reference. Please help me to solve the same.
Thanks !
Re: Accessing Remote PC in a different network with IP Address & Gateway
rameshiit19
...how can I explain....
well, the code line Socket soc = new Socket(args[0], 80); opens a socket to a standard port for a browser. Hence, you cannot open this port if you don't have a browser server. That's why you got the error with 127.0.0.1 and 121.242.63.60 (pic.2).
It must work with the whatismyipaddress.com because if you can access this site with a browser PingIP can ping it. The exception with whatismyipaddress.com was probably caused by the lack of an internet connection or it was not available. Question: 1) how you connect to this site? 2) can you "java PingIP www.javaprogrammingforums.com"? 3) what is about your access right?
Re: Accessing Remote PC in a different network with IP Address & Gateway
Thanks for the detailed reply.
I can access the site whatismyipaddress.com through my browser and I am unable to ping the same with the java program (PingIP) .My user account does not have complete admin rights . Only some of the accesses are allowed .
Re: Accessing Remote PC in a different network with IP Address & Gateway
...then your JAVA JRE (Java Runtime Environment) is NOT allowed to go thru the firewall. Ask your admin to do it for you :D.
Re: Accessing Remote PC in a different network with IP Address & Gateway
:(
I will try the same in some other PC where the firewall is not blocking it . Thanks a lot for your detailed explanations . :)
Re: Accessing Remote PC in a different network with IP Address & Gateway
8-|If you're sure that the Firewall won't block java I have to believe you. Then ...Sorry mate. I can't help because I can't remotely guess or debug your environment.