Return to Snippet

Revision: 35960
at November 15, 2010 13:14 by mouseroot


Initial Code
import javax.net.ssl.*;
import javax.net.*;
import java.net.*;
import java.io.*;


class ...

static BufferedReader in;
static BufferedWriter out;
static SocketFactory sockfact;
static Socket sock;


public static ...

try {

int port = 995;
String host = "pop.gmail.com";
SocketFactory sockfactory = SSLSocketFactory.getDefault();
Socket sock = sockfactory.createSocket(host,port);
in =  new BufferedReader(new InputStreamReader(sock.getInputStream()));
out = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream()));

//Send Data
out.write("data 
");
out.flush();

//recv Data
String line = in.readLine();

}catch(Exception er) {}

Initial URL

                                

Initial Description
Create a Socket that uses SSL :D

Initial Title
SSL Sockets in Java

Initial Tags

                                

Initial Language
Java