Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SSLServer {
- public static void main(String[] args) {
- try {
- int port = 443;
- ServerSocketFactory ssocketFactory = SSLServerSocketFactory.getDefault();
- ServerSocket ssocket = ssocketFactory.createServerSocket(port);
- // Listen for connections
- Socket socket = ssocket.accept();
- // Create streams to securely send and receive data to the client
- 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) {
- e.printStackTrace();
- }
- }
- }
- public class SSLClient {
- public static void main(String[] args) {
- 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) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement