diff options
Diffstat (limited to 'src/main/java/org/openslx/filetransfer/Transfer.java')
-rw-r--r-- | src/main/java/org/openslx/filetransfer/Transfer.java | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/main/java/org/openslx/filetransfer/Transfer.java b/src/main/java/org/openslx/filetransfer/Transfer.java index aebd3ce..c987576 100644 --- a/src/main/java/org/openslx/filetransfer/Transfer.java +++ b/src/main/java/org/openslx/filetransfer/Transfer.java @@ -4,21 +4,20 @@ import java.io.Closeable; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketTimeoutException; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; +import javax.net.SocketFactory; import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSocketFactory; - -import net.jpountz.lz4.LZ4Factory; import org.apache.logging.log4j.Logger; import org.openslx.util.Util; +import net.jpountz.lz4.LZ4Factory; + public abstract class Transfer { protected final Socket transferSocket; @@ -45,14 +44,10 @@ public abstract class Transfer { this.log = log; // create socket. - if ( context == null ) { - transferSocket = new Socket(); - } else { - SSLSocketFactory sslSocketFactory = context.getSocketFactory(); - transferSocket = sslSocketFactory.createSocket(); - } + transferSocket = Util.connectAllRecords( + context == null ? SocketFactory.getDefault() : context.getSocketFactory(), + host, port, 4000 ); transferSocket.setSoTimeout( readTimeoutMs ); - transferSocket.connect( new InetSocketAddress( host, port ), 4000 ); outStream = new DataOutputStream( transferSocket.getOutputStream() ); dataFromServer = new DataInputStream( transferSocket.getInputStream() ); |