Moved client creation from main to own thread.

This commit is contained in:
WickedJack99
2023-12-01 22:34:28 +01:00
parent 25a75cf35b
commit 088fbb86f1

View File

@@ -0,0 +1,29 @@
package connect.src;
public class ClientThread extends Thread {
private static final String className = "ClientThread";
public void run() {
// Get connection data from ui
// Connect to server
// Send data depending on information received from ui
// Handle reply of server, process data and display on ui
// Close connection to server before ui is getting closed
printMessage("Call testConnection.");
testConnection();
//sconn(fd=4, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='127.0.0.1', port=5000), raddr=addr(ip='127.0.0.1', port=33828), status='ESTABLISHED', pid=26828)
}
private void testConnection() {
Client client = new TLSClient(new TLSClientInformation("cacerts", "qwerty".toCharArray()));
client.createConnection();
client.sendData(null);
client.receiveData();
client.closeConnection();
}
private static void printMessage(String message) {
System.out.println(className + ": " + message);
}
}