SecureServer.java Source code

Java tutorial

Introduction

Here is the source code for SecureServer.java

Source

import java.net.*;
import java.io.*;
import javax.net.*;
import java.security.*;
import javax.net.ssl.*;
import javax.crypto.*;

public class SecureServer {
    public static void main(String[] args) throws Exception {
        ServerSocketFactory ssf = SSLServerSocketFactory.getDefault();
        SSLServerSocket ss = (SSLServerSocket) ssf.createServerSocket(98999);
        Socket sock = ss.accept();
        ss.close();
        OutputStream rawOut = sock.getOutputStream();
        PrintWriter out = new PrintWriter(new OutputStreamWriter(rawOut));
        out.println(new java.util.Date().toString());
        out.flush();
        sock.close();

    }
}