List of usage examples for javax.net.ssl SSLSocket setSoTimeout
public synchronized void setSoTimeout(int timeout) throws SocketException
From source file:com.sos.VirtualFileSystem.HTTP.EasySSLSocketFactory.java
@Override public Socket connectSocket(Socket sock, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket(params)); if (localAddress != null) { // we need to bind explicitly sslsock.bind(localAddress);/*from w w w . j av a2 s . co m*/ } sslsock.connect(remoteAddress, connTimeout); sslsock.setSoTimeout(soTimeout); return sslsock; }
From source file:edu.htl3r.schoolplanner.backend.network.Network.java
/** * Liefert ein {@link SSLSocket}, wenn eine Verbindung via SSL zum Server aufgebaut werden konnte oder 'null', wenn SSL nicht verfuegbar ist. * @param sa Die Adresse des Sockets, zum dem die Verbindung aufgebaut werden soll * @param set Ein Set mit {@link SSLSocket}s, mithilfe derer versucht werden soll, eine Verbindung aufzubauen * @return Das erste SSLSocket aus dem Set, mit dem eine problemlos Verbindung zum Server aufgebaut werden konnte oder 'null', wenn dies mit keinem moeglich war *///from w ww .j a va 2 s .co m private SSLSocket getWorkingSSLSocket(SocketAddress sa, Set<SSLSocket> set) { final int sslSocketTimeout = 2000; for (SSLSocket sslSocket : set) { try { sslSocket.connect(sa, sslSocketTimeout); sslSocket.setSoTimeout(sslSocketTimeout); sslSocket.setReuseAddress(true); sslSocket.startHandshake(); return sslSocket; } catch (IOException e) { } finally { try { sslSocket.close(); } catch (IOException e) { } } } return null; }
From source file:com.lolay.android.security.OpenSSLSocketFactory.java
@Override public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); InetSocketAddress remoteAddress = new InetSocketAddress(host, port); SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket()); if ((localAddress != null) || (localPort > 0)) { if (localPort < 0) { localPort = 0;// w w w . ja va 2 s . c o m } InetSocketAddress isa = new InetSocketAddress(localAddress, localPort); sslsock.bind(isa); } sslsock.connect(remoteAddress, connTimeout); sslsock.setSoTimeout(soTimeout); return sslsock; }
From source file:ucar.httpservices.CustomSSLProtocolSocketFactory.java
public Socket connectSocket(Socket sock, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpParams params) throws IOException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); SSLSocket sslsocket = (SSLSocket) ((sock != null) ? sock : createSocket(params)); if (localAddress != null) { sslsocket.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params)); sslsocket.bind(localAddress);//from w w w.ja v a 2 s . c o m } try { sslsocket.setSoTimeout(soTimeout); sslsocket.connect(remoteAddress, connTimeout); } catch (SocketTimeoutException ex) { throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out"); } return sslsocket; }
From source file:com.dvdprime.android.app.http.CustomSSLSocketFactory.java
@Override public Socket connectSocket(Socket socket, String reqHost, int reqPort, InetAddress arg3, int arg4, HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); InetSocketAddress remoteAddress = new InetSocketAddress(reqHost, reqPort); SSLSocket sslSocket = null; if (socket != null) { sslSocket = (SSLSocket) socket; } else {//from w ww . j av a 2 s . co m sslSocket = (SSLSocket) createSocket(); } InetSocketAddress inetSocketAddress = new InetSocketAddress(arg3, arg4); sslSocket.bind(inetSocketAddress); sslSocket.connect(remoteAddress, connTimeout); sslSocket.setSoTimeout(soTimeout); return sslSocket; }
From source file:com.manning.androidhacks.hack023.net.SimpleSSLSocketFactory.java
public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); InetSocketAddress remoteAddress = new InetSocketAddress(host, port); SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket()); if ((localAddress != null) || (localPort > 0)) { if (localPort < 0) { localPort = 0;// w w w .j av a 2s . co m } InetSocketAddress isa = new InetSocketAddress(localAddress, localPort); sslsock.bind(isa); } sslsock.connect(remoteAddress, connTimeout); sslsock.setSoTimeout(soTimeout); return sslsock; }
From source file:pt.hive.cameo.ssl.SSLSocketFactory.java
public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); InetSocketAddress remoteAddress = new InetSocketAddress(host, port); SSLSocket sslSocket = (SSLSocket) ((sock != null) ? sock : createSocket()); if ((localAddress != null) || (localPort > 0)) { if (localPort < 0) { localPort = 0;//from www. j a va 2s . c om } InetSocketAddress isa = new InetSocketAddress(localAddress, localPort); sslSocket.bind(isa); } sslSocket.connect(remoteAddress, connTimeout); sslSocket.setSoTimeout(soTimeout); return sslSocket; }
From source file:com.diaw.lib.tool.FakeSocketFactory.java
public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params) throws IOException { final int connTimeout = HttpConnectionParams.getConnectionTimeout(params); final int soTimeout = HttpConnectionParams.getSoTimeout(params); final InetSocketAddress remoteAddress = new InetSocketAddress(host, port); final SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket()); if ((localAddress != null) || (localPort > 0)) { // we need to bind explicitly if (localPort < 0) { localPort = 0; // indicates "any" }// ww w . ja v a 2 s.c om final InetSocketAddress isa = new InetSocketAddress(localAddress, localPort); sslsock.bind(isa); } sslsock.connect(remoteAddress, connTimeout); sslsock.setSoTimeout(soTimeout); return sslsock; }
From source file:com.aincc.ber.utils.FakeSocketFactory.java
@Override public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params) throws IOException { final int connTimeout = HttpConnectionParams.getConnectionTimeout(params); final int soTimeout = HttpConnectionParams.getSoTimeout(params); final InetSocketAddress remoteAddress = new InetSocketAddress(host, port); final SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket()); if ((localAddress != null) || (localPort > 0)) { // we need to bind explicitly if (localPort < 0) { localPort = 0; // indicates "any" }/* w w w.j a v a 2 s . com*/ final InetSocketAddress isa = new InetSocketAddress(localAddress, localPort); sslsock.bind(isa); } sslsock.connect(remoteAddress, connTimeout); sslsock.setSoTimeout(soTimeout); return sslsock; }
From source file:org.ttrssreader.net.deprecated.FakeSocketFactory.java
@Override public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params) throws IOException { int connTimeout = HttpConnectionParams.getConnectionTimeout(params); int soTimeout = HttpConnectionParams.getSoTimeout(params); InetSocketAddress remoteAddress = new InetSocketAddress(host, port); SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket()); if ((localAddress != null) || (localPort > 0)) { // we need to bind explicitly if (localPort < 0) { localPort = 0; // indicates "any" }//from ww w .j a v a 2 s . c om InetSocketAddress isa = new InetSocketAddress(localAddress, localPort); sslsock.bind(isa); } sslsock.connect(remoteAddress, connTimeout); sslsock.setSoTimeout(soTimeout); return sslsock; }