Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 15 of 15

Thread: Accessing Remote PC in a different network with IP Address & Gateway

  1. #1
    Member
    Join Date
    Sep 2010
    Posts
    32
    My Mood
    Confused
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Question 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 !


  2. #2
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default 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.

  3. #3
    Member
    Join Date
    Sep 2010
    Posts
    32
    My Mood
    Confused
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default 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

  4. #4
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default Re: Accessing Remote PC in a different network with IP Address & Gateway

    Quote Originally Posted by rameshiit19 View Post
    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)

  5. The Following User Says Thank You to Voodoo For This Useful Post:

    rameshiit19 (July 9th, 2012)

  6. #5
    Member
    Join Date
    Sep 2010
    Posts
    32
    My Mood
    Confused
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default 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 ?
    Last edited by rameshiit19; July 9th, 2012 at 06:56 AM.

  7. #6
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default Re: Accessing Remote PC in a different network with IP Address & Gateway

    Quote Originally Posted by rameshiit19 View Post
    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...

  8. The Following User Says Thank You to Voodoo For This Useful Post:

    rameshiit19 (July 10th, 2012)

  9. #7
    Member
    Join Date
    Sep 2010
    Posts
    32
    My Mood
    Confused
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default 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 ?

  10. #8
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default Re: Accessing Remote PC in a different network with IP Address & Gateway

    Quote Originally Posted by rameshiit19 View Post
    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:
    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>

  11. #9
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default Re: Accessing Remote PC in a different network with IP Address & Gateway

    ...and with this little program you can ping your own Internet IP

  12. #10
    Member
    Join Date
    Sep 2010
    Posts
    32
    My Mood
    Confused
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default 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 !
    Attached Images Attached Images

  13. #11
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default 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?

  14. #12
    Member
    Join Date
    Sep 2010
    Posts
    32
    My Mood
    Confused
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default 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 .

  15. #13
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default 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 .

  16. The Following User Says Thank You to Voodoo For This Useful Post:

    rameshiit19 (July 25th, 2012)

  17. #14
    Member
    Join Date
    Sep 2010
    Posts
    32
    My Mood
    Confused
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default 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 .

  18. #15
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default Re: Accessing Remote PC in a different network with IP Address & Gateway

    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.

Similar Threads

  1. the address of all connected machines to the network
    By ola50 in forum Java Networking
    Replies: 2
    Last Post: May 27th, 2012, 02:02 AM
  2. how can I make my Pc as a gateway programatecly
    By ola50 in forum Java Networking
    Replies: 0
    Last Post: May 22nd, 2012, 12:04 AM
  3. How can I get Remote Address from Object? (Java RMI)
    By sahin in forum Java Networking
    Replies: 1
    Last Post: February 4th, 2012, 10:02 PM
  4. Replies: 1
    Last Post: May 1st, 2011, 11:13 AM
  5. Replies: 8
    Last Post: August 6th, 2009, 02:35 PM