2 changed files with 44 additions and 13 deletions
@ -1,23 +1,53 @@ |
|||
package sample; |
|||
|
|||
import crypto.CryptoSocket; |
|||
import javafx.application.Application; |
|||
import javafx.fxml.FXMLLoader; |
|||
import javafx.scene.Parent; |
|||
import javafx.scene.Scene; |
|||
import javafx.stage.Stage; |
|||
|
|||
public class Main extends Application { |
|||
|
|||
@Override |
|||
public void start(Stage primaryStage) throws Exception{ |
|||
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml")); |
|||
primaryStage.setTitle("Hello World"); |
|||
primaryStage.setScene(new Scene(root, 300, 275)); |
|||
primaryStage.show(); |
|||
} |
|||
|
|||
import javax.xml.crypto.Data; |
|||
import java.io.*; |
|||
import java.net.ServerSocket; |
|||
import java.net.Socket; |
|||
|
|||
public class Main |
|||
{ |
|||
public static void main(String[] args) { |
|||
launch(args); |
|||
} |
|||
try |
|||
{ |
|||
ServerSocket sock = new ServerSocket(25519); |
|||
Socket s = new Socket("127.0.0.1", 25519); |
|||
System.out.println("launching other thread"); |
|||
new Thread(new Runnable() { public void run() { try |
|||
{ |
|||
CryptoSocket csock = new CryptoSocket(sock.accept()); |
|||
DataOutputStream out = csock.getOutputStream(); |
|||
DataInputStream in = csock.getInputStream(); |
|||
out.writeUTF("server->client"); |
|||
out.flush(); |
|||
synchronized (System.out) |
|||
{ |
|||
System.out.print("server: "); |
|||
System.out.println(in.readUTF()); |
|||
} |
|||
} catch (Exception e) {} } }).start(); |
|||
System.out.println("done; connecting socket"); |
|||
CryptoSocket csock = new CryptoSocket(s); |
|||
DataOutputStream out = csock.getOutputStream(); |
|||
DataInputStream in = csock.getInputStream(); |
|||
out.writeUTF("client->server"); |
|||
out.flush(); |
|||
synchronized (System.out) |
|||
{ |
|||
System.out.println("client: "); |
|||
System.out.println(in.readUTF()); |
|||
} |
|||
System.out.println("done"); |
|||
} catch (IOException e) |
|||
{ |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue