Ejemplo n.º 1
0
  /* start UDP listener */
  private ServerSocketThread _startUDP(int port) throws Throwable {
    ServerSocketThread sst = null;

    /* create server socket */
    try {
      sst = new ServerSocketThread(ServerSocketThread.createDatagramSocket(port));
    } catch (Throwable t) { // trap any server exception
      Print.logException("ServerSocket error", t);
      throw t;
    }

    /* initialize */
    sst.setTextPackets(Constants.ASCII_PACKETS);
    sst.setBackspaceChar(null); // no backspaces allowed
    sst.setLineTerminatorChar(Constants.ASCII_LINE_TERMINATOR);
    sst.setIgnoreChar(Constants.ASCII_IGNORE_CHARS);
    sst.setMaximumPacketLength(Constants.MAX_PACKET_LENGTH);
    sst.setMinimumPacketLength(Constants.MIN_PACKET_LENGTH);
    sst.setIdleTimeout(TrackServer.udpTimeout_idle);
    sst.setPacketTimeout(TrackServer.udpTimeout_packet);
    sst.setSessionTimeout(TrackServer.udpTimeout_session);
    sst.setTerminateOnTimeout(Constants.TERMINATE_ON_TIMEOUT);
    sst.setClientPacketHandlerClass(TrackClientPacketHandler.class);

    /* start thread */
    Print.logInfo(
        "Starting UDP listener thread on port "
            + port
            + " [timeout="
            + sst.getSessionTimeout()
            + "ms] ...");
    sst.start();
    this.udpThread.add(sst);
    return sst;
  }
Ejemplo n.º 2
0
  /* start TCP listener */
  private void _startTCP(int port) throws Throwable {
    ServerSocketThread sst = null;

    /* create server socket */
    try {
      sst = new ServerSocketThread(port);
    } catch (Throwable t) { // trap any server exception
      Print.logException("ServerSocket error", t);
      throw t;
    }

    /* initialize */
    sst.setTextPackets(Constants.ASCII_PACKETS);
    sst.setBackspaceChar(null); // no backspaces allowed
    sst.setLineTerminatorChar(Constants.ASCII_LINE_TERMINATOR);
    sst.setIgnoreChar(Constants.ASCII_IGNORE_CHARS);
    sst.setMaximumPacketLength(Constants.MAX_PACKET_LENGTH);
    sst.setMinimumPacketLength(Constants.MIN_PACKET_LENGTH);
    sst.setIdleTimeout(TrackServer.tcpTimeout_idle); // time between packets
    sst.setPacketTimeout(
        TrackServer.tcpTimeout_packet); // time from start of packet to packet completion
    sst.setSessionTimeout(TrackServer.tcpTimeout_session); // time for entire session
    sst.setTerminateOnTimeout(Constants.TERMINATE_ON_TIMEOUT);
    sst.setClientPacketHandlerClass(TrackClientPacketHandler.class);
    sst.setLingerTimeoutSec(Constants.LINGER_ON_CLOSE_SEC);

    /* start thread */
    Print.logInfo(
        "Starting TCP listener thread on port "
            + port
            + " [timeout="
            + sst.getSessionTimeout()
            + "ms] ...");
    sst.start();
    this.tcpThread.add(sst);
  }