• Post Reply Bookmark Topic Watch Topic
  • New Topic

Chat connecting  RSS feed

 
John Falco
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all.
I was hoping the somebody could help me with this. I recently made a chat app with client and server works great on my local network. You know 2 or more clients connect to the server and chat.

However, I would like to beable to use the same app (if I can) so that a friend mine and myself can chat even though he is not connected to my network.

I tried just giving him my server info (IP and socket). I thought he might beable to connect thru his internet connection.

Anyway, it didnt work.....I am new to java and networking/internet connections thru java. So I know I must be missing somthing big.


Can this work and if so how.....

Thanks for all your help
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If you can explain or give a rough idea about what the problem is? Can't connect is very generic. Are you getting an exception? or the UI freezes? etc. Regards.
 
John Falco
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about not being more specific. I ran the client app in netbeans because it very nicely will give me the error msgs.

I get connection refused as an error. on the client side

I dont have the a firewall on during the test as well.

Also, i dont get any output from the server side.

This is the connection code:

As you can see the user enters in the IP and socket that i give him.

private void setUpNetworking(){

String IPA;
String OSN;
int SN;



try {
IPA = (jTextField6.getText());
OSN=(jTextField7.getText());
SN = Integer.valueOf(OSN).intValue();


sock = new Socket(IPA, SN);


InputStreamReader streamReader = new InputStreamReader(sock.getInputStream());
reader = new BufferedReader(streamReader);
writer = new PrintWriter(sock.getOutputStream());
jLabel8.setText("Connected to Server");
} catch (IOException ex) {
ex.printStackTrace();
}


}

Thanks for your help
 
aslam parveez
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say you are running your server in your own machine and you have given the ip and port of your server to your friend to connect then it's a must for you to have the ip of your server recognized over the internet. For that you should have a static ip setup for your server registering over the internet.

Have you done that ?
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravens, welcome to the JavaRanch.
We don't have many rules around here, but we do have a strictly enforced naming policy. In short, your displayed name must be a first name and last name, separated by a space and not obviously fake. You can change your name here.
Thank you for your prompt attention.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!