Results 1 to 8 of 8
  1. #1
    tim's Avatar
    tim
    tim is offline Senior Member
    Join Date
    Dec 2007
    Posts
    435
    Rep Power
    7

    Wink Java networking.

    Hello everyone.

    I have a book called "Sams teach yourself java in 21 days" that I am currently using. In chapter 17, "Cummunicating Across the Internet", there are examples for creating servers using the ServerSocket class in the java.net package. I would like to know if it possible to create a simple connection between two computers connected via TCP-IP LAN, and not via the Internet. It would help if someone could give me an example of a server/client program using these classes or direct me to a suitable website or article.

    Thank you.
    Eyes dwelling into the past are blind to what lies in the future. Step carefully.

  2. #2
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    8

    Default

    It will be interesting to see a definitive answer on this. But I would just like to make a clarification here... whether the program goes over a LAN or through the Internet, you're still going with the program model of client/server, correct? So for the most part, it doesn't really matter which connection you use. I say this because in order to reach say Google, you'd use the IP of Google, but if you only wanted to connect to your LAN's server you'd use that local IP(192.168.0.xxx). I look forward to seeing a concrete example too, but I don't think it is much different from the previous connection via the Internet... conceptually. And technically speaking, this works the same for SSH. All that matters is whether your client machine is physically on the LAN or not, if it's not then it will not find the local IP, if it is - it will.
    Last edited by CaptainMorgan; 12-31-2007 at 12:36 AM.

  3. #3
    tim's Avatar
    tim
    tim is offline Senior Member
    Join Date
    Dec 2007
    Posts
    435
    Rep Power
    7

    Default Thanks

    Thank you CaptainMorgan. I'll try another Google search for an example. :o
    Eyes dwelling into the past are blind to what lies in the future. Step carefully.

  4. #4
    kinzo is offline Member
    Join Date
    Nov 2007
    Posts
    2
    Rep Power
    0

    Default

    hahahaha, are u sure

  5. #5
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    8

    Default

    Quote Originally Posted by kinzo View Post
    hahahaha, are u sure
    Hi kinzo, please quote whom you're replying to... are you replying to me? or Tim? Thanks!

  6. #6
    tim's Avatar
    tim
    tim is offline Senior Member
    Join Date
    Dec 2007
    Posts
    435
    Rep Power
    7

    Question Success

    Hello everyone.

    I have successfully created a network application that can act as a server or client for a network connection between two computers. The application is designed for instant messaging. I have tested the application at home and it works well. I would like to know, however, if my program will be able to work over the internet as well. I know CaptainMorgan said:
    So for the most part, it doesn't really matter which connection you use.
    but, I cannot test that for myself.

    Thanks everyone for the help so far. :D
    Eyes dwelling into the past are blind to what lies in the future. Step carefully.

  7. #7
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    8

    Default

    If you tested it at home then it should work given the new IP address you list for the client of the server is a valid one. I assume for the home test you used, 127.0.0.1? Provided firewalls and the like, and port is available, it might be as simple as changing the localhost address to the new one.

    I realized the above paragraph might be a slight repetition of my previous post Tim. This morning I just finished building a client/server app of my own which represents a chat room, likely similar to your IM'ng app. I'm pretty sure the IP address change I mention solves it - I know this because I tested mine via my local machine via 127... and I also uploaded it to my remote server and it was a success.

    Let us know what you come up with ;)
    Last edited by CaptainMorgan; 01-05-2008 at 07:41 PM.
    Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
    Want to voice your opinion on your IDE/Editor of choice? Vote now!
    Got a little Capt'n in you? (drink responsibly)

  8. #8
    willhts is offline Member
    Join Date
    Jul 2009
    Posts
    1
    Rep Power
    0

    Default Virtual domain question

    Hi, I am new to java networking, and i have a problem.

    I have a customer who has a virtual domain address:

    h t t p //somewords.some-other-words.cag:80/somepath/somefile.jsp

    This is set up as a profile property in my software.

    However: If I try to create a URL object with the above url, it gives an error.

    java.net.ConnectException: Connection timed out: connect
    Jul 15 11:39:59 2009: SPID: 26 at java.net.PlainSocketImpl.socketConnect(Native Method)
    Jul 15 11:39:59 2009: SPID: 26 at java.net.PlainSocketImpl.doConnect(PlainSocketImpl .java:305)
    Jul 15 11:39:59 2009: SPID: 26 at java.net.PlainSocketImpl.connectToAddress(PlainSoc ketImpl.java:171)
    Jul 15 11:39:59 2009: SPID: 26 at java.net.PlainSocketImpl.connect(PlainSocketImpl.j ava:158)

    If I use the actual machine name:

    h t t p //actualservername:80/somepath/somefile.jsp

    The URL gets created.

    If I put the virtual domain url in a web browser, it does bring up the same jsp that putting the actualservername url does.

    So the question is: should the virtual domain work when creating a URL object and they just have something set up wrong on their network?

    or is there a method I need to call on the virtual domain (similar to getHost), that returns the actualservername, and then use that to create the URL Object?

    Thanks (sorry the h t t p is spaced out, Forum thinks I am trying to advertise)

Similar Threads

  1. Java networking programming (II)
    By Java Tutorial in forum Java Tutorial
    Replies: 0
    Last Post: 12-27-2007, 07:19 PM
  2. Java networking programming (I)
    By Java Tutorial in forum Java Tutorial
    Replies: 0
    Last Post: 12-24-2007, 08:21 PM
  3. Multithreading + Networking (desperate)
    By bluebarca in forum New To Java
    Replies: 1
    Last Post: 11-07-2007, 03:14 PM

Posting Permissions

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