Wouldn't call myself a network programming expert, but here is my code: import javax.net.ssl.SSLSocketFactory;
// Create a socket without connecting SSLSocketFactory socketFactory = SSLSocketFactory.getDefault(); Socket socket socket = socketFactory.createSocket(); // Connect, with an explicit timeout value socket.connect(new InetSocketAddress(endpoint.mServer, endpoint.mPort), CONNECT_TIMEOUT); // Set read timeout socket.setSoTimeout(DATA_TIMEOUT); // SSL negotiation happens here, which is why setSoTimeout has to be called before InputStream streamInput = socket.getInputStream(); OutputStream streamOutput = socket.getOutputStream(); ... and so on and so forth. These sockets are not for HTTP, and if yours are not either, my gut feeling tells me that using Apache HTTP classes would be strange. -- K 2013/6/20 Nathan <[email protected]>: > Hi > > I'm sure you have all done much more network programming than me. > > My colleague has created a trusted secure socket connection using these > classes. > > import javax.net.SocketFactory; > import javax.net.ssl.SSLContext; > import javax.net.ssl.TrustManagerFactory; > > In the field, it is getting a > java.net.SocketTimeoutException: Connection timed out > > We both noticed that within the Android Tree, there are more choices for > SocketFactory's than we have exploited. > > There is also. > org.apache.http.conn.ssl.SSLSocketFactory > > So, without starting any holy wars, which one is "better"? > > Right now, we are thinking the apache one, because it allows you to specify > httpparams that it honors for the socket connectionTimeout. > We'd probably set it at 20 seconds, since thats what AndroidHttpClient does. > > But in the control group, I have no idea what the timeout is now. I know it > is not zero, because that would imply infinite waiting, and it appears that > the client may be giving up when the server was ready to respond. > > If we call > SSLContext.getInstance("TLS").getSocketFactory().createSocket(SERVER, PORT); > What timeouts will it have? > > I tried grepping the source code and got lost. > > Nathan > > -- > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Android Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > -- -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

