[1528] in java-interest
Data streams and networking on Win95
daemon@ATHENA.MIT.EDU (Andrew Gilmartin)
Thu Sep 7 00:06:00 1995
From: Andrew Gilmartin <ajg@brainiac.com>
To: "'Java Interest'" <java-interest@java.sun.com>
Date: Wed, 6 Sep 1995 21:08:22 -0400
Attached is a small test program that sends an int from a client to a
server. When run on a Windows 95 box the int is received by the server as
-1 and not as the sent 12345. Given that network byte ordering is a well
known problem I must be missing something, but can't find it in the doc.
Any ideas? Thanks.
(Are primative data types stored in the platform format? The VM guide does
not say. If this is so then the bit shifting done in the data stream
classes might be the cause of the problem.)
-- Andrew (ajg@brainiac.com)
import net.*;
import java.io.*;
class Server extends NetworkServer {
public void serviceRequest() {
System.out.println( "servicing request" );
DataInputStream in = new DataInputStream( clientInput );
int i = in.readInt();
System.out.println( i );
// String s = in.readUTF();
// System.out.println( s.length() );
// System.out.println( s );
System.out.flush();
}
}
class Main {
public static void main( String args[] ) {
Server server = new Server();
server.startServer( 4000 );
NetworkClient client = new NetworkClient();
client.openServer( "edgework", 4000 );
DataOutputStream out = new DataOutputStream( client.serverOutput );
out.writeInt( 12345 );
// out.writeUTF( "Hello World" );
client.closeServer();
}
}
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com