/****************************************************************************/
/* Copyright (c) 2007 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : _atsServer.cc                                                 */
/* Author   :                                                               */
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 06/08/2007                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
/*-----------------------------------------------------------------------*
  PROGRAM: atsServer

  DESCRIPTION: Binary wrapper for AtsServer

  AUTHOR: Rich Henthorn

  *-----------------------------------------------------------------------*/

#include <stdlib.h>
#include "AtsServer.h"
#include "Syslog.h"
#include "System.h"

int main( int argc, char **argv )
{
  // Set task priority
  if (System::setTaskPriority(CriticalServerPriority) == -1)
    return 1;

  int port;
  if (argc < 2)
  {
    printf("Usage: atsServer socket_port_number\nEx: atsServer 9009\n");
    return 1;
  }
  
  sscanf(argv[1], "%d", &port);
  if (port <= 0)
  {
    printf("Usage: atsServer socket must be > 0\n");
    return 1;
  }
  
  printf("atsServer(%d)\n", port);
  try {
    AtsServer *server = new AtsServer(port);
    server->run();
  }
  catch( Exception e ) {
    Syslog::write("sonardyneServer -- Caught exception: %s\n", e.msg );
  }
  catch( ... ) {
    Syslog::write("sonardyneServer -- Caught exception!\n");
  }

  return 0;
}
