private void handleConnect() { try { int program_version = ois.readInt(); port = ois.readInt(); address = listenSocket.getInetAddress(); netCode = ois.readInt(); Connection c = checkConnectionNetCode(); if (c != null) { oos.writeInt(ALREADY_CONNECTED); oos.flush(); System.out.println("->ALREADY_CONNECTED"); // $NON-NLS-1$ } else { if (isAcceptingConnections()) { if (connections.size() < Utils.getMAX_CONNECTIONS()) { if (Utils.VERSION == program_version) { Connection newConnection = newConnection(); if (newConnection != null) { oos.writeInt(CONNECTED); newConnection.setState(Connection.STATE_CONNECTED); System.out.println("->CONNECTED"); // $NON-NLS-1$ } else { oos.writeInt(ALREADY_CONNECTED); System.out.println("->ALREADY_CONNECTED"); // $NON-NLS-1$ } oos.flush(); } else { oos.writeInt(INCOMPATIBLE_PROGRAM_VERSION); oos.flush(); System.out.println("->INCOMPATIBLE_PROGRAM_VERSION"); // $NON-NLS-1$ } } else { oos.writeInt(TOO_MANY_CONNECTIONS); oos.flush(); System.out.println("->TOO_MANY_CONNECTIONS"); // $NON-NLS-1$ } } else { oos.writeInt(NOT_ACCEPTING_CONNECTIONS); oos.flush(); System.out.println("->NOT_ACCEPTING_CONNECTIONS"); // $NON-NLS-1$ } } } catch (IOException ex) { System.out.println(ex.getMessage()); } }