public void connectionStarting(ConnectionEvent e) throws ConnectionVetoException {
   ipList.put(e.getConnectionModel().getHostAddress(), null);
   // check on the max connections
   GnutellaConnection conn = ((GnutellaConnectionEvent) e).getConnection();
   GnutellaConnectionModel model = (GnutellaConnectionModel) e.getConnectionModel();
   boolean maxReached = false;
   switch (model.getConnectionType()) {
     case GnutellaConnectionModel.INCOMING:
       synchronized (this) {
         if (currentIncomingConnections >= maxIncomingConnections) maxReached = true;
         // if it hasn't been reached, then increment and continue
         currentIncomingConnections++;
       }
       break;
     case GnutellaConnectionModel.OUTGOING:
       synchronized (this) {
         if (currentOutgoingConnections >= maxOutgoingConnections) maxReached = true;
         // if it hasn't been reached, then increment and continue
         currentOutgoingConnections++;
       }
       break;
   }
   // record the connection into the list
   synchronized (activeConnections) {
     activeConnections.add(conn);
   }
   conn.addMessageListener(listMsgListener);
   fireConnectionStartingWithoutVeto(e);
   if (maxReached) throw new ConnectionVetoException("Max Connection Reached!");
 }