Code example for SSLSocketFactory

Methods: createSocket

    PrintWriter output;
    public EmailService(String server, int port) {
	try { 
	    SSLSocketFactory sslsocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
	    socket = (SSLSocket) sslsocketFactory.createSocket(server, port);
	    input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
	    // After each println you MUST flush the buffer, or it won't work 
	    // properly. 
	    // The true argument makes an automatic flush after each println. 
	    output = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()), true);
	} catch (UnknownHostException e) {
	} catch (IOException e) {
    public String readOneLine() throws IOException {
Experience pair programming with AI  Get Codota for Java