I can't get more than one applet communicating with my Cpp server
For some reason when I connect one Java client to my Cpp server it works perfectly. But when another Java applet tries to connect in addition to the first, it does but it stops receiving data from the server. Some of the other attempts would completly freeze the applet. I have searched everywhere on the 'net but found nothing. I would appreciate any help on the subject like advice, links or source. My only other option (since Flash is out of t开发者_JAVA百科he question) is to use Active X, but then I would lose all my crossplatform-ability :(. My source (minus debugging code and so on) follows.
public void init() {
try {
socket = new Socket("localhost",4000);
} catch (UnknownHostException e) {
System.out.println("Unknown host");
} catch (IOException e) {
System.out.println("IO Exception");
return;
}
BufferedReader fromServer = null;
PrintWriter toServer = null;
fromServer = new BufferedReader(
new InputStreamReader(socket.getInputStream()));
toServer =
new PrintWriter(socket.getOutputStream(), true);
toServer.flush();
It sounds like your Cpp server can't handle multiple connections. Can you verify that you can accept more than one incoming network connection?
I found the solution! You can't run multiple applets in one browser and one machine. It will work if you load them in seperate browsers (like IE and FF) or load it on a seperate machine (like remotely). I hope this helps.
精彩评论