Results 1 to 14 of 14
  1. #1
    ThisIsJAVA is offline Member
    Join Date
    Mar 2012
    Location
    Greece
    Posts
    10
    Rep Power
    0

    Default Chat only works localy.

    Greetings fellow programmers.
    I have constructed a chat application. However i have some toruble with the connections. When i insert IPs of the type 192.164.1.3 it works just fine. But i want it to work like all over the internet. I inserted IPs like 85.72.134.3 which as i read are the external ones that do such a job. When i run the client is goes all like <<connection timeout>> and nothing seems to happen. Does anyone know why this is happening? if yes how do i fix it? Thank you for your time :)

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,298
    Rep Power
    20

    Default Re: Chat only works localy.

    Apart from your username, what does any of that have to do with Java?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    ThisIsJAVA is offline Member
    Join Date
    Mar 2012
    Location
    Greece
    Posts
    10
    Rep Power
    0

    Default Re: Chat only works localy.

    my application is all built in java. what does your question mean exactly?
    i have methods that get the first kind of ip. and give it to the socket to make conection. When i get the second kind of ip it doesnt work. i find your question rather confusing sir.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,298
    Rep Power
    20

    Default Re: Chat only works localy.

    Quote Originally Posted by ThisIsJAVA View Post
    my application is all built in java. what does your question mean exactly?
    My question means, exactly, that your original post doesn't even mention that the problem relates to a Java program, and that in the absence of any Java code it is not possible for any member here to suggest a Java solution for the problem.

    Indeed, I still think your problem is unrelated to your Java code.

    Moving to Networking.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,298
    Rep Power
    20

    Default Re: Chat only works localy.

    Moved from New to Java

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    ThisIsJAVA is offline Member
    Join Date
    Mar 2012
    Location
    Greece
    Posts
    10
    Rep Power
    0

    Default Re: Chat only works localy.

    well this is a java forum . so my problem ought to be bout java. I am merely wondering if the java sockets need something more than just the 85.72.134.3 to work. i provide that and a port number.

    this is the call. :
    Socket socket = new Socket("85.72.134.3", 100);

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,298
    Rep Power
    20

    Default Re: Chat only works localy.

    Quote Originally Posted by ThisIsJAVA View Post
    well this is a java forum . so my problem ought to be bout java.
    You'd be surprised to know how many threads are locked and later removed because they aren't related to Java; and then there are the non-technical questions that are moved to the forum lobby.

    If your first post isn't clear on that, we have to ask. Would you prefer a Java forum cluttered with non-Java questions just because no moderator ever asked the question?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  8. #8
    ThisIsJAVA is offline Member
    Join Date
    Mar 2012
    Location
    Greece
    Posts
    10
    Rep Power
    0

    Default Re: Chat only works localy.

    By no means am i questioning the management of this forum. I was only trying to explain why i posted the thread where i posted it. I consider my question pretty <<basic>> to put it kindly. so i posted it in the <<new to java>> section. I havent worked with sockets before this application. The answer will probably be something really obvious. thats why i did not post it as a networking problem. I shall make clearer posts in the future. Thank you for taking the time to explain. Spiros

  9. #9
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: Chat only works localy.

    I think what DB is saying is that it sounds like a network problem, not a Java problem at all. But there's no way to tell unless you post some code.

    And when you do post code, nobody wants to read and take the time to understand a bunch of huge classes. So it's a good idea to boil the problem down to a SSCCE. I find that when I attempt to demonstrate a question in a SSCCE, I often answer it myself.
    Get in the habit of using standard Java naming conventions!

  10. #10
    ThisIsJAVA is offline Member
    Join Date
    Mar 2012
    Location
    Greece
    Posts
    10
    Rep Power
    0

    Default Re: Chat only works localy.

    Well if it is a network problem this does not mean it is not a java problem. I like to consider this a network problem in java. So this wud make it an item of two categories therefore enabling the poster to freely choose where to post it. I have thoroughly explained why i posted it there. Plus I hardly believe theres any code required for what i want to know. I have provided the reader with a single line that is the crucial part. What i wanted to know was if the ip number is enough to achieve the connection. If not what else is needed. Isnt this a simple ,easy to comprehend question?
    Sumarising :
    ServerSocket listener = new ServerSocket(100); server
    Socket socket = new Socket("85.72.134.2", 100); client
    am i doing this rite? or do i need to add something?

  11. #11
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: Chat only works localy.

    Is 85.72.134.2 the public IP address of the machine on which your program is running?
    Get in the habit of using standard Java naming conventions!

  12. #12
    ThisIsJAVA is offline Member
    Join Date
    Mar 2012
    Location
    Greece
    Posts
    10
    Rep Power
    0

    Default Re: Chat only works localy.

    yes. i use this code to get it
    URL getip = new URL("http://automation.whatismyip.com/n09230945.asp");
    BufferedReader br = new BufferedReader(new InputStreamReader(
    getip.openStream()));
    String ip = br.readLine();
    i believe this does the job.

  13. #13
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: Chat only works localy.

    That method may not give you the public IP of the machine the program is running on. In fact, if you are on any kind of private network - university, business, or home network with a router - then your computer probably does not have a public IP address at all.

    Have a look at Listing Network Interface Addresses (The Java™ Tutorials > Custom Networking > Programmatic Access to Network Parameters).
    Get in the habit of using standard Java naming conventions!

  14. #14
    ThisIsJAVA is offline Member
    Join Date
    Mar 2012
    Location
    Greece
    Posts
    10
    Rep Power
    0

    Default Re: Chat only works localy.

    Thank you. i shall have a look at the url you provided me with. There is definitely a public ip. I double checked it with some sites and it seems that this is indeed my ip. And the code is as it should be. Showed it to a few people and they said if it works localy and give it the proper ip it will work outside the lan as well. Im starting to suspect that that the reason i cant connect is related to security. Though i would be getting a proper pop-up stating that my program was blocked or sonething wouldnt i.

Similar Threads

  1. Replies: 4
    Last Post: 03-31-2011, 10:37 PM
  2. Tell me how this loop works.
    By hydride in forum New To Java
    Replies: 6
    Last Post: 05-13-2010, 04:50 AM
  3. String.contains works in jdk 6, not in 1.4.2
    By ScottThornley in forum New To Java
    Replies: 1
    Last Post: 04-16-2010, 03:04 PM
  4. Anyone know how GroupLayout works?
    By ProgrammingPup in forum Advanced Java
    Replies: 5
    Last Post: 12-01-2009, 11:12 PM
  5. Replies: 7
    Last Post: 03-31-2009, 01:29 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •