Client to Server Network Problem

my java client wont connect to my java server

Page 1 of 1

6 Replies - 1082 Views - Last Post: 11 August 2009 - 04:41 PM Rate Topic: -----

#1 painkiller102  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 16
  • View blog
  • Posts: 281
  • Joined: 27-February 08

Client to Server Network Problem

Posted 10 August 2009 - 06:17 PM

I have been working on this server for like 4 hours today and finally got it done, running and working to my preference. I then made a client that would simply look at the server and tell the user if the server is on, full or off. Working on a LAN using my IP "192.168.0.2", the client will connect successfully (whoopdy do, i know). So i decided to send the Client to a friend and see if he could connect to the server as well. I modified the code to be my "External IP Address" so my friend could connect and the Client used the following code: (i blocked out my external IP Address for security purposes!
	public class client extends SwingWorker<Integer, Integer>
	{
		private Socket server;
		protected Integer doInBackground()
		{
			try
			{
				String address = "xx.xxx.xxx.xx";
				InetAddress ip = InetAddress.getByName(address);
				m.loginServStats.setText("Scanning..");
				m.loginServStats.setForeground(Color.WHITE);
				try
				{
					server = new Socket(ip,port);
					m.loginServStats.setText("Online");
					m.loginServStats.setForeground(Color.GREEN);
					server.close();
				}
				catch(Exception exe)
				{
					m.loginServStats.setText("Offline / Full");
					m.loginServStats.setForeground(Color.RED);
				}
			}
			catch(Exception ex)
			{
				System.out.println("IP Error");
			}
			return 0;
		}
	}



Now The code does work and does not error out, however my friend still cannot connect to my java server. Any ideas or suggestions?

Is This A Good Question/Topic? 0
  • +

Replies To: Client to Server Network Problem

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8343
  • View blog
  • Posts: 31,890
  • Joined: 06-March 08

Re: Client to Server Network Problem

Posted 10 August 2009 - 06:41 PM

192.168.0.XXX are internal IP adresses used at thousands places in the world
you have to give your router or the address provided by your ISP to your friend
then the router has to know to which host (your computer) it has to forward the connections to port N
Was This Post Helpful? 0
  • +
  • -

#3 painkiller102  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 16
  • View blog
  • Posts: 281
  • Joined: 27-February 08

Re: Client to Server Network Problem

Posted 10 August 2009 - 06:52 PM

View Postpbl, on 10 Aug, 2009 - 05:41 PM, said:

192.168.0.XXX are internal IP adresses used at thousands places in the world
you have to give your router or the address provided by your ISP to your friend
then the router has to know to which host (your computer) it has to forward the connections to port N


Ok. well we just preformed more tests and yes, it is a network problem on my end. It seems my router will not let traffic threw. do you know of any useful tutorials on this matter? i cant figure out how to make my router accept others traffic and what not.
Was This Post Helpful? 0
  • +
  • -

#4 H3R3T1C  Icon User is offline

  • Android Expert
  • member icon

Reputation: 277
  • View blog
  • Posts: 757
  • Joined: 30-March 07

Re: Client to Server Network Problem

Posted 10 August 2009 - 06:58 PM

View Postpainkiller102, on 10 Aug, 2009 - 05:52 PM, said:

Ok. well we just preformed more tests and yes, it is a network problem on my end. It seems my router will not let traffic threw. do you know of any useful tutorials on this matter? i cant figure out how to make my router accept others traffic and what not.

Yes we preformed a network test and was able to get it to work on my desktop running XP. I seem to have the same problem hosting on my laptop though. I used to be able but along the line somewhere it seems some settings have changed and now can host on laptop.
Was This Post Helpful? 0
  • +
  • -

#5 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8343
  • View blog
  • Posts: 31,890
  • Joined: 06-March 08

Re: Client to Server Network Problem

Posted 10 August 2009 - 07:55 PM

Sure it will reach your router which has a unique IP address
Then you have to inform the router to redirect a connection for a particular port to which internal host

Image you have a PC running as server for an application on port 3000 and this PC address is 192.168.0.100
Image you have a PC running as server for an application on port 4000 and this PC address is 192.168.0.200

Now your router address can be 123.123.123.123
your external users will try to connect to 123.123.123.123 port 3000 and 123.123.123.123 port 4000
your router has to redirect connection to port 3000 to 192.168.0.100 and
your router has to redirect connection to port 4000 to 192.168.0.200

so on your router configuration tool/menu there is a way to set that
Was This Post Helpful? 0
  • +
  • -

#6 painkiller102  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 16
  • View blog
  • Posts: 281
  • Joined: 27-February 08

Re: Client to Server Network Problem

Posted 11 August 2009 - 08:32 AM

View Postpbl, on 10 Aug, 2009 - 06:55 PM, said:

Sure it will reach your router which has a unique IP address
Then you have to inform the router to redirect a connection for a particular port to which internal host

Image you have a PC running as server for an application on port 3000 and this PC address is 192.168.0.100
Image you have a PC running as server for an application on port 4000 and this PC address is 192.168.0.200

Now your router address can be 123.123.123.123
your external users will try to connect to 123.123.123.123 port 3000 and 123.123.123.123 port 4000
your router has to redirect connection to port 3000 to 192.168.0.100 and
your router has to redirect connection to port 4000 to 192.168.0.200

so on your router configuration tool/menu there is a way to set that


Thanks. that's one part of the problem down. The ports are now running fine however something is still blocking the incoming traffic....My firewall is disabled and everything so really there shouldn't be anything blocking the signal. is there anything else i am missing that may block the signal? Ive heard that a software firewall will block the signals, however I do not believe i have a software firewall Installed? Is there another system that could be running and blocking incoming traffic that anyone knows of?

This post has been edited by painkiller102: 11 August 2009 - 08:47 AM

Was This Post Helpful? 0
  • +
  • -

#7 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8343
  • View blog
  • Posts: 31,890
  • Joined: 06-March 08

Re: Client to Server Network Problem

Posted 11 August 2009 - 04:41 PM

The problem might be in your server application.
Why do you say it is your firewall or whatever taht blocks the traffic ?
Do you have a sniffer installed that let you know for sure that the packets do not pass through ?
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1