src/main/java/pityoulish/sockets/server/Main.java
public static void main(String[] args)
    throws Exception
  {
    //@@@ get network interface from command line arguments, too?
    //@@@ Use ArgsInterpreter and SingleCommandHandlerBase?
    int port = 2888; // default for the exercises
    int capacity = 8;

    try {
      if (args.length > 0)
         port = Integer.parseInt(args[0]);
      if (args.length > 1)
         capacity = Integer.parseInt(args[1]);
    } catch (NumberFormatException nfx) {
      System.out.println(nfx);
      System.out.println(Catalog.fixEOL(Catalog.USAGE.lookup()));
      System.exit(1);
    }

    LogConfig.configure(Main.class);
    LOGGER.log(Level.INFO, "starting Message Board server");

    MixedMessageBoard      mmb  = new MixedMessageBoardImpl(capacity);
    TicketManager          tim  = new DefaultTicketManager();

    mmb.putSystemMessage(null, Catalog.SYSMSG_OPEN.lookup());
    mmb.putSystemMessage(null, Catalog.SYSMSG_CAPACITY_1.format(capacity));

    SocketHandler shandler = createTLVSocketHandler(mmb, tim, true, true);
    shandler.startup(port, 0); // adjusting the backlog is pointless

    System.out.println(shandler);
    System.out.println(shandler.getServerSocket());

    Thread.sleep(3600000); // milliseconds
    shandler.shutdown();
  }
/**
   * Main entry point.
   *
   * @param args        the command line arguments
   *
   * @throws Exception  in case of a problem
   */
Main entry point.
@param args        the command line arguments

@throws Exception  in case of a problem
Main entry point . @param args the command line arguments @throws Exception in case of a problem
public static void main(String[] args)
    throws Exception
  {
    int port = 2888; 
    int capacity = 8;
    try {
      if (args.length > 0)
         port = Integer.parseInt(args[0]);
      if (args.length > 1)
         capacity = Integer.parseInt(args[1]);
    } catch (NumberFormatException nfx) {
      System.out.println(nfx);
      System.out.println(Catalog.fixEOL(Catalog.USAGE.lookup()));
      System.exit(1);
    }
    LogConfig.configure(Main.class);
    LOGGER.log(Level.INFO, "starting Message Board server");
    MixedMessageBoard      mmb  = new MixedMessageBoardImpl(capacity);
    TicketManager          tim  = new DefaultTicketManager();
    mmb.putSystemMessage(null, Catalog.SYSMSG_OPEN.lookup());
    mmb.putSystemMessage(null, Catalog.SYSMSG_CAPACITY_1.format(capacity));
    SocketHandler shandler = createTLVSocketHandler(mmb, tim, true, true);
    shandler.startup(port, 0); 
    System.out.println(shandler);
    System.out.println(shandler.getServerSocket());
    Thread.sleep(3600000); 
    shandler.shutdown();
  }
public static void main ( String [ ] args ) throws Exception { int port = 2888 ; int capacity = 8 ; try { if ( args . length > 0 ) port = Integer . parseInt ( args [ 0 ] ) ; if ( args . length > 1 ) capacity = Integer . parseInt ( args [ 1 ] ) ; } catch ( NumberFormatException nfx ) { System . out . println ( nfx ) ; System . out . println ( Catalog . fixEOL ( Catalog . USAGE . lookup ( ) ) ) ; System . exit ( 1 ) ; } LogConfig . configure ( Main . class ) ; LOGGER . log ( Level . INFO , "starting Message Board server" ) ; MixedMessageBoard mmb = new MixedMessageBoardImpl ( capacity ) ; TicketManager tim = new DefaultTicketManager ( ) ; mmb . putSystemMessage ( null , Catalog . SYSMSG_OPEN . lookup ( ) ) ; mmb . putSystemMessage ( null , Catalog . SYSMSG_CAPACITY_1 . format ( capacity ) ) ; SocketHandler shandler = createTLVSocketHandler ( mmb , tim , true , true ) ; shandler . startup ( port , 0 ) ; System . out . println ( shandler ) ; System . out . println ( shandler . getServerSocket ( ) ) ; Thread . sleep ( 3600000 ) ; shandler . shutdown ( ) ; }
Main entry point.
Main entry point .
//@@@ get network interface from command line arguments, too? //@@@ Use ArgsInterpreter and SingleCommandHandlerBase? // default for the exercises // adjusting the backlog is pointless // milliseconds