Hi there
I will probably be up all night trying to figure this out but maybe somebody here can help me keep from turning into a giant cup of coffee.....
I am just beginning to learn to program Java applets. I need to open an input and output stream to a socket on the same server that serves the applet.
I open the socket and I can send output to the socket, but I never seem to receive input on the socket. A call such as:
String line = inputstream.readLine();
will hang the applet even though I am sending several lines to it.
Here is the basic code I am using to set everything up:
Socket s = new Socket( "192.168.1.1", 9999 );
DataInputStream inputstream = new DataInputStream( s.getInputStream() );
PrintStream outputstream = new PrintStream( s.getOutputStream() );
outputstream.println("i can send output"
String temp = inputstream.readLine();
... and it will never get past that line. And basically I have a simple server running which will allow multiple clients to connect, and when output is sent from any one it is echoed to all of the clients that are connected. If I connect with telnet to the proper port everything seems to work fine. Also, I can write a Java application on the server and execute it and it receives input fine using the same basic code.
Is there something Im missing about applets and sockets??
Something odd happened while I was trying to figure this out. Somehow I managed to create an endless loop sending to the output stream and when I opened the applen on a Windows 2000 Server in IE it gave me a blue screen that said it was writing physical memory to disk and counted to 100 and when it reached 100 it rebooted the box... I just thought that was an interesting security hole...
Anyways if somebody can help me out with my socket problem I would be much obliged.
Thanks,
Gerald
I will probably be up all night trying to figure this out but maybe somebody here can help me keep from turning into a giant cup of coffee.....
I am just beginning to learn to program Java applets. I need to open an input and output stream to a socket on the same server that serves the applet.
I open the socket and I can send output to the socket, but I never seem to receive input on the socket. A call such as:
String line = inputstream.readLine();
will hang the applet even though I am sending several lines to it.
Here is the basic code I am using to set everything up:
Socket s = new Socket( "192.168.1.1", 9999 );
DataInputStream inputstream = new DataInputStream( s.getInputStream() );
PrintStream outputstream = new PrintStream( s.getOutputStream() );
outputstream.println("i can send output"
String temp = inputstream.readLine();
... and it will never get past that line. And basically I have a simple server running which will allow multiple clients to connect, and when output is sent from any one it is echoed to all of the clients that are connected. If I connect with telnet to the proper port everything seems to work fine. Also, I can write a Java application on the server and execute it and it receives input fine using the same basic code.
Is there something Im missing about applets and sockets??
Something odd happened while I was trying to figure this out. Somehow I managed to create an endless loop sending to the output stream and when I opened the applen on a Windows 2000 Server in IE it gave me a blue screen that said it was writing physical memory to disk and counted to 100 and when it reached 100 it rebooted the box... I just thought that was an interesting security hole...
Anyways if somebody can help me out with my socket problem I would be much obliged.
Thanks,
Gerald