Making classes final to make inheritance impossible
[iot2.git] / iotjava / iotrmi / Java / IoTSocketClient.java
index 961719cf2ae113a42999d8c364f7e7ea17ad1cf4..5fad560536c315d4519f574819d023883d9338dc 100644 (file)
@@ -18,13 +18,13 @@ import java.util.*;
  * @version     1.0
  * @since       2016-08-17
  */
-public class IoTSocketClient extends IoTSocket {
+public final 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();
+       }
 }