I can't write data to more then one client applet
I have a problem. I am developing a applet that connects to a C++ server. For some reason when I launch a second applet in a new IE8 window I cannot write to it but I can still read. Any text going to the second client applet is not getting through. I signed the jar file for my applet and can run it with IE8. I a开发者_如何学JAVAm using Windows 7 with JCreator for my Java. Any suggestions would be appreciated.
HTML
<html>
<head>
</head>
<body bgcolor="000000">
<center>
<applet
archive="javafree.jar"
code="javafree.class"
width="800"
height="500">
<param name="player" value="scar" />
</applet>
</center>
</body>
</html>
Code
socket = new Socket( "localhost", 4000 );
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
out = new PrintStream( socket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(classlink.socket.getInputStream()));
if( in.ready() ) {
gametext += "<br><font color='#7DE5FF'>" + in.readLine() + "</font><br>";
classlink.textman.setText(gametext);
}
You obviously overwrite your input stream with something not related to this socket (classlink
suggests something class-level, static?) here:
in = new BufferedReader(
new InputStreamReader(
socket.getInputStream()));
...
in = new BufferedReader(
new InputStreamReader(
classlink.socket.getInputStream()));
精彩评论