[5632] in java-interest
Applet woes
daemon@ATHENA.MIT.EDU (Raymond Harrison - TCI/AIT)
Tue Feb 20 18:41:47 1996
From: rharriso@elmer.tcinc.com (Raymond Harrison - TCI/AIT)
To: java-interest@java.sun.com
Date: Tue, 20 Feb 1996 15:05:17 -0700 (MST)
Howdie All -
I have written a Sybase Client in AWT that
communicates with a Java SYBASE Server handling basic
queries and returning the results to display in the
Client list box. It is (or will be) a port of
Tom Poindexter's WISQL program. It works great
as a stand-alone application and it also works
if you call it through Netscape. However, if you try
to use it WITHIN netscape, the DataInputStream of the
server receives a null string. I know that either
applets/or netscape have certain restrictions concerning
socket communications. Just one question: Is this what
I am running into or is it something else?
SNIPPET OF CODE USED:
SERVER: try
{
if (socket == null) {
socket = new ServerSocket(port_number, count);
}
}
catch(IOException e)
{
System.out.println("Can not open socket");
System.exit(0);
}
System.out.println("Waiting for client connection.");
if (connection == null) {
connection = socket.accept();
System.out.println("Connection made");
System.out.println("Connection = "+connection);
din = new DataInputStream(
new BufferedInputStream(connection.getInputStream()));
dout = new DataOutputStream(
new BufferedOutputStream(connection.getOutputStream()));
System.out.println("DIN IS "+din);
}
System.out.println("Waiting for data.");
try {
//
//
//
//
//THIS IS NULL WHEN RECEIVED FROM THE CLIENT
//
//
//
//
qry = new String(din.readUTF());
} catch (java.io.IOException ioe) {
System.out.println("ERROR IS "+ioe.getMessage());
ioe.printStackTrace();
}
CLIENT
public class Client extends java.applet.Applet
{
static int I=0;
public static int count;
public static int col;
boolean die = false;
public static String[] message;
public static DataInputStream din;
public static DataOutputStream dout;
..
..
..
..
try
{
socket = new Socket(host, port_number);
}
catch(IOException e)
{
System.out.println("Can not open socket");
System.exit(0);
}
din = new DataInputStream(
new BufferedInputStream(socket.getInputStream()));
dout = new DataOutputStream(
new BufferedOutputStream(socket.getOutputStream()));
System.out.println("OUTPUT STREAM IS "+dout);
..
..
..
..
qry = new String(qa.getText());
System.out.println("Text is "+qry);
qry.trim();
dout.writeUTF(qry);
dout.flush();
ANY IDEAS? ANYONE?
Thanks -
Ray Harrison
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com