First benchmark working with capability-based RMI; adjustments in callbacks, etc.
[iot2.git] / iotjava / iotrmi / Java / IoTSocket.java
index 66089c95cd34ddfffa05a33602e78e67fd9d358e..848a2e97265cfd2dedaf5bbdbc76e64c7d2c7238 100644 (file)
@@ -50,7 +50,7 @@ public abstract class IoTSocket {
        /**
         * sendBytes() sends an array of bytes
         */
-       public void sendBytes(byte vals[]) throws IOException
+       public synchronized void sendBytes(byte vals[]) throws IOException
        {
                int len = vals.length;
                // Write the length first - convert to array of 4 bytes
@@ -69,11 +69,12 @@ public abstract class IoTSocket {
        /**
         * receiveBytes() receives an array of bytes
         */
-       public byte[] receiveBytes(byte val[]) throws IOException
+       public synchronized byte[] receiveBytes(byte val[]) throws IOException
        {
                int i;
                int totalbytes = 0;
                int numbytes;
+
                // Wait until input is available
                while(input.available() == 0);
                // Read the maxlen first - read 4 bytes here
@@ -104,7 +105,7 @@ public abstract class IoTSocket {
        /**
         * Close socket connection
         */
-       public void close() throws IOException
+       public synchronized void close() throws IOException
        {
                sock.close();
        }
@@ -113,7 +114,7 @@ public abstract class IoTSocket {
        /**
         * Send ACK
         */
-       public void sendAck() throws IOException
+       public synchronized void sendAck() throws IOException
        {
                int ack;
                ack = 0;
@@ -125,7 +126,7 @@ public abstract class IoTSocket {
        /**
         * Receive ACK
         */
-       public void receiveAck() throws IOException
+       public synchronized void receiveAck() throws IOException
        {
                int ack;
                ack = (int) input.read();