Hello I would need help to Convert this type of Server and Client Comunication from Java to C#. I need this for a school project. What is the fastest way to accomplish my Mission
public class Server {
ServerSocket socket;
public Server() throws IOException {
socket=new ServerSocket(1234);
}
public void run() throws IOException {
while(true){
Socket client = socket.accept();
ClientThread ct= new ClientThread(client);
ct.run();
}
}
}
public class ClientThread {
protected Socket socket;
PrintWriter clientOut;
BufferedReader clientIn;
public ClientThread(Socket socket) throws IOException {
this.socket = socket;
clientOut=new PrintWriter(new BufferedOutputStream(socket.getOutputStream()));
clientIn=new BufferedReader(new InputStreamReader(socket.getInputStream()));
}
public void run() throws IOException {
boolean runWhile =true;
while(runWhile) {
senden("Hallo Client");
String msg = clientIn.readLine();
if(msg.equals("end")){
runWhile=false;
}
System.out.println(msg);
}
socket.close();
}
public void senden(String msg){
clientOut.println(msg);
clientOut.flush();
}
}
public class Client {
ArrayList<RegisterEntry> entries=new ArrayList<>();
Socket clientSocket;
PrintWriter clientOut;
BufferedReader clientIn;
Database db = new Database();
public Client() throws IOException {
clientSocket = new Socket("127.0.0.1" , 1234);
clientOut= new PrintWriter(new BufferedOutputStream(clientSocket.getOutputStream()));
clientIn= new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
}
public void run() throws IOException, SQLException {
testing();
}
public void senden(String message){
clientOut.println(message);
clientOut.flush();
}
public void testing() throws SQLException, IOException {
//Nachricht vom Server holen
String msg= clientIn.readLine();
System.out.println(msg);
//Antworten
String answer = "Hey Server";
senden(answer);
//Data probieren
db.insertData(2, LocalDateTime.now(), "javaInsert", "Test insert in Java", "Baraness");
RegisterEntry registerEntry1= db.getData(2);
senden(registerEntry1.toString());
senden ("end");
}
}