Java

[Java] Creating an SSL Client Socket

빤따스뤽 2007. 1. 9. 21:44

try
{
int port = 443;
String hostname = "hostname";
SocketFactory socketFactory = SSLSocketFactory.getDefault();
Socket socket = socketFactory.createSocket(hostname, port);

// Create streams to securely send and receive data to the server
InputStream in = socket.getInputStream();
OutputStream out = socket.getOutputStream();

// Read from in and write to out...

// Close the socket
in.close();
out.close();
}
catch(IOException e)
{
}