more changes
authorbdemsky <bdemsky>
Tue, 6 Nov 2007 05:36:37 +0000 (05:36 +0000)
committerbdemsky <bdemsky>
Tue, 6 Nov 2007 05:36:37 +0000 (05:36 +0000)
Robust/src/ClassLibrary/InetAddress.java
Robust/src/Runtime/socket.c

index 1ecbddae59d98c21f13c18c86cd6879f56abb499..7d44a3dbf36d82dc6fa3554bc2f47c2ab4288901 100644 (file)
@@ -20,6 +20,21 @@ public class InetAddress {
        return address;
     }
 
+    public static InetAddress getLocalHost() {
+       return getByName("localhost");
+    }
+
+    public boolean equals(InetAddress ia) {
+       if (ia==null)
+           return false;
+       if (ia.address.length!=address.length)
+           return false;
+       for(int i=0;i<address.length;i++)
+           if (ia.address[i]!=address[i])
+               return false;
+       return true;
+    }
+
     public static InetAddress[] getAllByName(String hostname) {
        InetAddress[] addresses;
        
@@ -34,4 +49,14 @@ public class InetAddress {
     }
 
     public static native byte[][] getHostByName(byte[] hostname);
+
+    public String toString() {
+       String h=hostname+" ";
+       for (int i=0;i<address.length;i++) {
+           if (i>0)
+               h+=".";
+           h+=(int)address[i];
+       }
+       return h;
+    }
 }
index 69e7c12d83d4b50ea56127032165fa35353e363e..e550a76a1276f3024c67aec1367e96d4d3473e54 100644 (file)
@@ -192,6 +192,13 @@ int CALL12(___ServerSocket______createSocket____I, int port, struct ___ServerSoc
 #endif
   }
 
+#ifdef MAC
+        if (setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &n, sizeof (n)) < 0) {
+         perror("socket");
+         exit(-1);
+       }
+#endif
+
 #ifdef TASK
   fcntl(fd, F_SETFD, 1);
   fcntl(fd, F_SETFL, fcntl(fd, F_GETFL)|O_NONBLOCK);
@@ -308,14 +315,12 @@ int CALL02(___Socket______nativeRead_____AR_B, struct ___Socket___ * ___this___,
   struct listitem *tmp=stopforgc((struct garbagelist *)___params___);
 #endif
 #endif
-  int byteread;
+  int byteread=-1;
 
   //  printf("Doing read on %d\n",fd);
-  while(1) {
+  do {
     byteread=read(fd, charstr, length);
-    
-    break;
-  }
+  } while(byteread==-1&&errno==EINTR);
 #ifdef THREADS
 #ifdef PRECISE_GC
   restartaftergc(tmp);
@@ -334,7 +339,6 @@ int CALL02(___Socket______nativeRead_____AR_B, struct ___Socket___ * ___this___,
   if (byteread<0) {
     printf("ERROR IN NATIVEREAD\n");
     perror("");
-    byteread=0;
   }
 #ifdef TASK
   flagorand(VAR(___this___),0,0xFFFFFFFE);