Working Java v.1.0 for arbitrary calls of callback objects
[iot2.git] / iotjava / iotrmi / Java / IoTSocketClient.java
index 961719cf2ae113a42999d8c364f7e7ea17ad1cf4..4338b0ebc00fc264a95fa4d585fa03fb3921a317 100644 (file)
@@ -24,7 +24,7 @@ public class IoTSocketClient extends IoTSocket {
         * Default constructor
         */
        public IoTSocketClient(int _port, String _address, int rev) throws IOException
-       {
+               {
                super(_port);
                try {
                        sock = new Socket( InetAddress.getByName(_address), port );
@@ -38,4 +38,24 @@ public class IoTSocketClient extends IoTSocket {
                output.write(rev);
                output.flush();
        }
+
+       /**
+        * Additional constructor
+        */
+       public IoTSocketClient(int _localPort, int _port, String _address, int rev) throws IOException
+       {
+               super(_localPort, _port);
+               try {
+                       sock = new Socket( InetAddress.getByName(_address), 
+                                               port, InetAddress.getByName(_address), localPort );
+                       input = new BufferedInputStream(sock.getInputStream(), BUFFSIZE);
+                       output = new BufferedOutputStream(sock.getOutputStream(),BUFFSIZE);
+               }
+               catch ( IOException e ) {
+                       e.printStackTrace();
+               }
+               // now we want to tell the server if we want reversed bytes or not
+               output.write(rev);
+               output.flush();
+       }
 }