Merge "Add SSLCertificateSocketFactory.setSoWriteTimeout to allow SO_SNDTIMEO to be specified" into jb-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5a009dcc58
@ -21,6 +21,7 @@ import android.util.Log;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.net.SocketException;
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import javax.net.SocketFactory;
|
import javax.net.SocketFactory;
|
||||||
@ -341,6 +342,22 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory {
|
|||||||
castToOpenSSLSocket(socket).setHostname(hostName);
|
castToOpenSSLSocket(socket).setHostname(hostName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets this socket's SO_SNDTIMEO write timeout in milliseconds.
|
||||||
|
* Use 0 for no timeout.
|
||||||
|
* To take effect, this option must be set before the blocking method was called.
|
||||||
|
*
|
||||||
|
* @param socket a socket created by this factory.
|
||||||
|
* @param timeout the desired write timeout in milliseconds.
|
||||||
|
* @throws IllegalArgumentException if the socket was not created by this factory.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public void setSoWriteTimeout(Socket socket, int writeTimeoutMilliseconds)
|
||||||
|
throws SocketException {
|
||||||
|
castToOpenSSLSocket(socket).setSoWriteTimeout(writeTimeoutMilliseconds);
|
||||||
|
}
|
||||||
|
|
||||||
private static OpenSSLSocketImpl castToOpenSSLSocket(Socket socket) {
|
private static OpenSSLSocketImpl castToOpenSSLSocket(Socket socket) {
|
||||||
if (!(socket instanceof OpenSSLSocketImpl)) {
|
if (!(socket instanceof OpenSSLSocketImpl)) {
|
||||||
throw new IllegalArgumentException("Socket not created by this factory: "
|
throw new IllegalArgumentException("Socket not created by this factory: "
|
||||||
|
Reference in New Issue
Block a user