SocketInputStream bug?

Archie Cobbs archie at whistle.com
Tue Aug 18 14:00:20 PDT 1998


It looks like SocketInputStream is missing the "int read()" method.
While the fallback to FileInputStream probably works OK under UNIX,
it may be different under Windows.. ?

There also are a couple of other methods which it appears
need to be defined, to override the FileInputStream versions.

-Archie

___________________________________________________________________________
Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com

Index: SocketInputStream.java
===================================================================
RCS file: /cvs/mod/net/kaffe/libraries/javalib/java/net/SocketInputStream.java,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.2.1
diff -c -u -r1.1.1.1 -r1.1.1.1.2.1
--- SocketInputStream.java	1998/07/14 16:49:41	1.1.1.1
+++ SocketInputStream.java	1998/08/18 20:11:41	1.1.1.1.2.1
@@ -15,14 +15,26 @@
 class SocketInputStream
   extends FileInputStream
 {
-	boolean eof;
-/* Do I need this? */
-	SocketImpl impl;
-	byte[] temp;
 
+public boolean markSupported() {
+	return false;
+}
+
+public long skip(long num) throws IOException {
+	byte junk[]=new byte[(int) num];
+	return (long)read(junk);
+}
+
 public SocketInputStream(SocketImpl impl) {
 	super(impl.fd);
-	this.impl=impl;
+}
+
+public int read() throws IOException {
+	byte[] b = new byte[1];
+	if (read(b, 0, 1) != 1) {
+		return -1;
+	}
+	return b[0];
 }
 
 public int read(byte b[]) throws IOException {
@@ -33,6 +45,5 @@
 	return socketRead(b, off, length);
 }
 
-/* I have no idea what this is for */
-native private int socketRead(byte buf[], int offset, int len);
+native private int socketRead(byte buf[], int offset, int len) throws IOException;
 }


More information about the kaffe mailing list