Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.IOException;
- import java.io.ObjectInputStream;
- import java.io.ObjectOutputStream;
- import java.net.ServerSocket;
- import java.net.Socket;
- import java.util.ArrayList;
- public class Main {
- private static ServerSocket server;
- private Socket Con;
- private static ObjectOutputStream serveroutput;
- private static ObjectInputStream serverinput;
- private static Socket serverconnection;
- private ArrayList<Socket> cons;
- public Main() throws IOException {
- try {
- this.server = new ServerSocket(2021);
- System.out.println("server gestartet");
- waitforcon();
- } catch (IOException e) {
- System.out.println("Server startup Error");
- e.printStackTrace();
- }
- }
- public void waitforcon() throws IOException {
- while(true) {
- try {
- this.Con = server.accept();
- serversetupStreams();
- System.out.println("client verbunden" + Con.getInetAddress());
- this.cons.add(Con);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- private void serversetupStreams() throws IOException{
- System.out.println("baue brΓΌcken");
- serveroutput = new ObjectOutputStream(Con.getOutputStream());
- serveroutput.flush();
- serverinput = new ObjectInputStream(Con.getInputStream());
- }
- private void waitforping() throws ClassNotFoundException, IOException {
- while(true) {
- String[] cmd = (String[]) serverinput.readObject();
- verwerten(cmd);
- /*char[] cmd = s.toCharArray();
- int countpart = 0;
- for(int i = cmd.length; i > 0; i++) {
- if(cmd[i] == '.') {
- countpart++;
- int vor = i;
- for(int z = vor; z >0;z--) {
- char[] be1 = new char[z];
- be1[z] = cmd[z];
- }
- }
- }*/
- }
- }
- public void verwerten(String[] a) {
- }
- public static void main(String[] args) throws IOException {
- new Main();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement