hello i m trying to write a chat application..
but i m getting few errors in the code, here is the code:
Server1.java
Client.java
The first problem i m getting is, i am able to connect to my network only (i mean able to communicate with those machines which are in my network/same network), how do i connect to others networks??
The second problem is i can communicate only to one machine/client at a time, if other is trying to run client.java (shows no error), but not able to communicate??
Punit Jain wrote:
The first problem i m getting is, i am able to connect to my network only (i mean able to communicate with those machines which are in my network/same network), how do i connect to others networks??
If the host you're connecting to isn't on your LAN, then either it has to have a public IP address, or it has to be behind a router that has a public IP address and that is doing port-forwarding to that host.
Note that the normal way to run a chat application isn't to have all the participants directly connect to each other. Rather, they all connect to a central server that does have a public IP address, and that server acts as a relay for the messages.
Punit Jain wrote:
The second problem is i can communicate only to one machine/client at a time, if other is trying to run client.java (shows no error), but not able to communicate??
What do you mean? What exact problem are you having if you try to run two clients? I notice that your server only allows one connection over its lifetime. Is that what you're asking about? How to connect multiple clients to the same server?
A server is usually structured something like:
Punit Jain
Ranch Hand
Joined: Aug 20, 2011
Posts: 902
posted
0
How to connect multiple clients to the same server?