posted 16 years ago
hi ranchers
could anyone help my to understand the problem in my chatting program
1. in my program there is a server running (main server) for public
chatting and many clients loggs on that server.
2. evrey client have a list of his freinds when he click on any of them he
starts a private chat with his freind.
3. when the client click on his frind's name he retreveis his ip from the
server and he try to connect to his freind (now his freind will act as
server and he will act as client)and start a private chat.
this program is working properly on the LAN but when i work on the internet
the private chat unforunaitly ain't work and the client(Socket) couldn't connect to his freind (ServerSocket), the client throws the following exception
java.net.ConnectException:Connect refused:connection timeout.
i think the porblem is near this fragment of code
-----------------------------------------------------------------------
Socket client=new Socket();
InetAddress inet=InetAddress.getByName(urls);//urls is the ip of other peer
client.connect(new InetSocketAddress(inet,2050),0);
-----------------------------------------------------------------------
and i use the same fragment when i connect to the main server(public chat server).
-----------------------------------------------------------------------
Socket client=new Socket();
InetAddress inet=InetAddress.getByName("www.mycompany.com");
client.connect(new InetSocketAddress(inet,2050),0);
-----------------------------------------------------------------------
and it works properly.
plz if there any solving to my problem if not
tell my why my program doesn't work on the internet.
thanks in advance..