Results 1 to 8 of 8
Thread: Java networking.
- 12-30-2007, 05:17 PM #1
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.
- 12-31-2007, 12:34 AM #2
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.
- 12-31-2007, 06:00 PM #3
Thank you CaptainMorgan. I'll try another Google search for an example. :oEyes dwelling into the past are blind to what lies in the future. Step carefully.
- 01-02-2008, 03:22 PM #4Member
- Join Date
- Nov 2007
- Rep Power
hahahaha, are u sure
- 01-02-2008, 06:58 PM #5
- 01-05-2008, 07:25 PM #6
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.
Thanks everyone for the help so far. :DEyes dwelling into the past are blind to what lies in the future. Step carefully.
- 01-05-2008, 07:31 PM #7
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.
- 07-16-2009, 11:43 PM #8Member
- Join Date
- Jul 2009
- Rep Power
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)
- By Java Tutorial in forum Java TutorialReplies: 0Last Post: 12-27-2007, 07:19 PM
- By Java Tutorial in forum Java TutorialReplies: 0Last Post: 12-24-2007, 08:21 PM
- By bluebarca in forum New To JavaReplies: 1Last Post: 11-07-2007, 03:14 PM