random class library stuff
authorbdemsky <bdemsky>
Wed, 7 Nov 2007 09:55:12 +0000 (09:55 +0000)
committerbdemsky <bdemsky>
Wed, 7 Nov 2007 09:55:12 +0000 (09:55 +0000)
Robust/src/ClassLibrary/Socket.java
Robust/src/ClassLibrary/String.java

index c8b796e310f50f2b10e33f1e1915309ddc9173e5..89a7792849a18fcae0f0ea678166ae372a2c2458 100644 (file)
@@ -4,6 +4,7 @@ public class Socket {
     /* File Descriptor */
     int fd;
     private SocketInputStream sin;
+    private SocketOutputStream sout;
     
     public Socket() {
        sin=new SocketInputStream(this);
@@ -14,7 +15,7 @@ public class Socket {
        return sin;
     }
 
-    public OutputSream getOutputStream() {
+    public OutputStream getOutputStream() {
        return sout;
     }
 
@@ -29,6 +30,11 @@ public class Socket {
        nativeConnect(fd, address.getAddress(), port);
     }
 
+    public void connect(InetAddress address, int port) {
+       fd=nativeBind(address.getAddress(), port);
+       nativeConnect(fd, address.getAddress(), port);
+    }
+
     public static native int nativeBind(byte[] address, int port);
 
     public native int nativeConnect(int fd, byte[] address, int port);
@@ -44,7 +50,7 @@ public class Socket {
        nativeWrite(b, 0, b.length);
     }
 
-    public void write(byte[] b, int offset, int leng) {
+    public void write(byte[] b, int offset, int len) {
        nativeWrite(b, offset, len);
     }
 
index 174525860b2177d45511ecbd9acbf378181fd60f..99481c09b26fd48150dabe9cad702543e1b199b9 100644 (file)
@@ -25,6 +25,17 @@ public class String {
        this.offset=0;
     }
 
+    public String(byte str[], int offset, int length) {
+       if (length>(str.length-offset))
+           length=str.length-offset;
+       char charstr[]=new char[length];
+       for(int i=0;i<length;i++)
+           charstr[i]=(char)str[i+offset];
+       this.value=charstr;
+       this.count=str.length;
+       this.offset=0;
+    }
+
     public String(String str) {
        this.value=str.value;
        this.count=str.count;