Results 1 to 5 of 5
Thread: client server problem
- 02-11-2010, 09:06 PM #1
Member
- Join Date
- Nov 2009
- Posts
- 28
- Rep Power
- 0
client server problem
Hi,
I'm trying to learn client-server programming in Java.
I have a Linux box that is running a server program with the port number 1564.
I wrote a java-client to connect to this server and communicate with.
I have a LAN and I ran the java-client on it, everything works fine. This is how I made a socket inside my LAN:
Java Code:Socket skt = new Socket(InetAddress.getByName("192.168.0.5"), 1564);
The next step is to try to connect via internet. My LAN is behind a DLink-dir320 router. This router has an admin interface with port forwarding facility. I defined the port 1564. It is obligatory to also mention the name of the protocol for the communication with the defined port. I still don't know how to do this in my Java program, as I don't use a standard protocol like HTTP, I just gave a random name. Then I saved changes. My Linux machine has not a firewall (I'm testing things only!). Finally, I changed the IP in my java-client to point to the public IP that my ISP assigned me (statically). I have another Linux box connected to this router and running Apache, and I serve one site on it and it is working correctly, so no problem with the IP. Now the jclient defines the socket this way:
When I run it what happens as you guess? Nothing works! :DJava Code:Socket skt = new Socket(InetAddress.getByName("89.361.21.152"), 1564);
My one and only guess about it is the protocol name under the router, but how to solve it? Or maybe you know that the problem must be somewhere else? Also, even though I used try-catch and various possible exceptions defined, I don't receive any error! Well program ran in LAN right, so has no problem itself probably, then how to debug in such a case?
Any idea is very appreciated :)
(English is not my native language)
- 02-12-2010, 06:11 AM #2
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
You might try taking out the 'getByName', as it's superfluous and might be causing problems if your IP is not in a DNS table (which it surely isn't). Also, sometime port number lower than 10000 are locked out, so you might try a higher port number.
Java Code:Socket skt = new Socket("89.361.21.152", 1564);
- 02-12-2010, 07:24 AM #3
Member
- Join Date
- Nov 2009
- Posts
- 28
- Rep Power
- 0
Thank you Toadaly, I took out 'getByName', and also defined the port as 10500, but it didn't work either :(
Again from inside LAN it works fine, but for outside, it can't.
The reason should not be that I am not using a known protocol like HTTP, but this came to my head because in my previous project I wrote an XML-RPC client under Java that connected via my Apache server to Joomla XML-RPC server, and on the same IP it worked fine! I used:
So may be this is all because of the protocol name? Any more suggestion please? :confused:Java Code:XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); try { config.setServerURL(new URL("http://89.361.21.152:80/brian/xmlrpc/")); } catch (MalformedURLException e1) { e1.printStackTrace(); }Last edited by kievari; 02-12-2010 at 07:27 AM.
- 02-12-2010, 07:30 AM #4
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
I doubt it's the protocol name. I've done things exactly like what you're trying to do....and really, so does every peer-to-peer system out there.
I'd guess it's either a bug in your code, you have the IP wrong, or it's a router/firewall issue.
- 02-12-2010, 08:06 AM #5
Member
- Join Date
- Nov 2009
- Posts
- 28
- Rep Power
- 0
Similar Threads
-
Client to Server, ClassNotFound Package Problem
By pwnzer in forum New To JavaReplies: 3Last Post: 11-07-2009, 09:17 PM -
Simple server/client text problem
By Singing Boyo in forum New To JavaReplies: 5Last Post: 06-02-2009, 10:33 AM -
Client Server socket problem - help needed
By kellaw in forum Threads and SynchronizationReplies: 6Last Post: 10-03-2008, 06:49 PM -
passing info between server/client problem
By DarkBlaze in forum New To JavaReplies: 13Last Post: 07-24-2008, 03:14 AM -
client-server communication problem
By revathi17 in forum New To JavaReplies: 1Last Post: 08-09-2007, 02:21 PM


LinkBack URL
About LinkBacks


Bookmarks