?? simpleclient.java~11~
字號:
package com.ssl;
import java.net.*;
import java.io.*;
import javax.net.ssl.*;
public class SimpleClient {
public static void main(String args[]) throws IOException {
InetAddress hostIA = InetAddress.getByName(args[0]);
String host = hostIA.getHostName();
int port = Integer.parseInt(args[1]);
System.out.println("USAGE: java SimpleClient host port");
try {
System.out.println("connecting...");
SSLSocketFactory sslFact =
(SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket c = (SSLSocket) sslFact.createSocket(host, port);
SSLContext sslContext = SSLContext.getInstance("SSL","SunJSSE");
sslContext.init(null, null, new java.security.SecureRandom());
SSLSocketFactory factory = sslContext.getSocketFactory();
SSLSocket socket = (SSLSocket)factory.createSocket("localhost", 7002);
System.out.println("handshaking...");
String s[] = c.getSupportedCipherSuites();
for(int i = 0;i<s.length;i++){
System.out.println(s[i]);
}
c.startHandshake();
BufferedReader in =
new BufferedReader(
new InputStreamReader(c.getInputStream()));
PrintWriter out = new PrintWriter(
new BufferedWriter(
new OutputStreamWriter(
c.getOutputStream())));
BufferedReader stdin =
new BufferedReader(
new InputStreamReader(System.in));
String line;
String strin;
for (; ; ) {
System.out.print("Enter a line:");
strin = stdin.readLine();
if (strin.length() == 0) {
break;
}
out.println(strin);
out.flush();
line = in.readLine();
System.out.println("Msg from Server is: " + line);
}
in.close();
out.close();
c.close();
System.out.println("done...");
} catch (IOException e) {
System.out.println("SimpleClient died: " + e.getMessage());
e.printStackTrace();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -