Exemplo n.º 1
0
static void Usage(const char *pProgName)
{
  fprintf(stderr, "Usage (client mode):\n");
  fprintf(stderr, "    %s [options] \\\\.\\<com port> <host addr> <host port>\n", pProgName);
  fprintf(stderr, "\n");
  fprintf(stderr, "Usage (server mode):\n");
  fprintf(stderr, "    %s [options] \\\\.\\<com port> <listen port>\n", pProgName);
  fprintf(stderr, "\n");
  fprintf(stderr, "Common options:\n");
  fprintf(stderr, "    --telnet              - use Telnet protocol.\n");
  fprintf(stderr, "    --terminal <type>     - use terminal <type> (RFC 1091).\n");
  fprintf(stderr, "    --help                - show this help.\n");
  fprintf(stderr, "\n");
  fprintf(stderr, "COM port options:\n");
  fprintf(stderr, "    --baud <b>            - set baud rate to <b> (default is %ld),\n",
                                               (long)ComParams().BaudRate());
  fprintf(stderr, "                            where <b> is %s.\n",
                                               ComParams::BaudRateLst());
  fprintf(stderr, "    --data <d>            - set data bits to <d> (default is %ld), where <d> is\n",
                                               (long)ComParams().ByteSize());
  fprintf(stderr, "                            %s.\n",
                                               ComParams::ByteSizeLst());
  fprintf(stderr, "    --parity <p>          - set parity to <p> (default is %s), where <p> is\n",
                                               ComParams::ParityStr(ComParams().Parity()));
  fprintf(stderr, "                            %s.\n",
                                               ComParams::ParityLst());
  fprintf(stderr, "    --stop <s>            - set stop bits to <s> (default is %s), where <s> is\n",
                                               ComParams::StopBitsStr(ComParams().StopBits()));
  fprintf(stderr, "                            %s.\n",
                                               ComParams::StopBitsLst());
  fprintf(stderr, "    --ignore-dsr          - ignore DSR state (do not wait DSR to be ON before\n");
  fprintf(stderr, "                            connecting to host, do not close connection after\n");
  fprintf(stderr, "                            DSR is OFF and do not ignore any bytes received\n");
  fprintf(stderr, "                            while DSR is OFF).\n");
  fprintf(stderr, "\n");
  fprintf(stderr, "    The value d[efault] above means to use current COM port settings.\n");
  fprintf(stderr, "\n");
  fprintf(stderr, "Client mode options:\n");
  fprintf(stderr, "    --awak-seq <sequence> - wait for awakening <sequence> from com port\n"
                  "                            before connecting to host. All data before\n"
                  "                            <sequence> and <sequence> itself will not be sent.\n");
  fprintf(stderr, "    --interface <if>      - use interface <if> for connecting.\n");
  fprintf(stderr, "\n");
  fprintf(stderr, "Server mode options:\n");
  fprintf(stderr, "    --interface <if>      - use interface <if> for listening.\n");
  exit(1);
}
Exemplo n.º 2
0
static void CALLBACK Help(const char *pProgPath)
{
  cerr
  << "Usage  (client mode):" << endl
  << "  " << pProgPath << " ... [--use-driver=" << GetPluginAbout()->pName << "] [*]<host addr>:<host port> ..." << endl
  << "Usage  (server mode):" << endl
  << "  " << pProgPath << " ... [--use-driver=" << GetPluginAbout()->pName << "] [*][!][/]<listen port>[/<priority>] ..." << endl
  << endl
  << "  The sign * above means that connection should be permanent as it's possible." << endl
  << "  In client mode it will force connection to remote host on start." << endl
  << "  The sign ! above means that connection to <listen port> should be rejected if" << endl
  << "  the connection counter is 0." << endl
  << "  The sign / above means that after disconnecting the port will be busy until" << endl
  << "  the connection counter is 0." << endl
  << "  The <priority> above is an integer (default is 0). The port will be used only" << endl
  << "  if all ports with the same <listen port> and higher <priority> are busy." << endl
  << endl
  << "Options:" << endl
  << "  --interface=<if>         - use interface <if>." << endl
  << "  --reconnect=<t>          - enable/disable forcing connection to remote host" << endl
  << "                             on disconnecting and set reconnect time. Where <t>" << endl
  << "                             is a positive number of milliseconds or d[efault]" << endl
  << "                             or n[o]. If sign * is not used then d[efault]" << endl
  << "                             means n[o] else d[efault] means 0." << endl
  << "  --write-limit=<s>        - set write queue limit to <s> (" << ComParams().WriteQueueLimitStr() << " by default)," << endl
  << "                             where <s> is " << ComParams::WriteQueueLimitLst() << ". The queue" << endl
  << "                             will be purged with data lost on overruning." << endl
  << "                             The value 0 will disable writing to the port." << endl
  << endl
  << "Output data stream description:" << endl
  << "  LINE_DATA(<data>) - send <data> to remote host." << endl
  << "  CONNECT(TRUE) - increment connection counter." << endl
  << "  CONNECT(FALSE) - decrement connection counter." << endl
  << endl
  << "In client mode if there is not connection to remote host the incrementing of" << endl
  << "the connection counter will force connection to remote host." << endl
  << "If sign * is not used and there is connection to remote host the decrementing" << endl
  << "of the connection counter to 0 will force disconnection from remote host and" << endl
  << "will disable forcing connection to remote host till incrementing connection" << endl
  << "counter." << endl
  << endl
  << "Input data stream description:" << endl
  << "  LINE_DATA(<data>) - received <data> from remote host." << endl
  << "  CONNECT(TRUE) - connected to remote host." << endl
  << "  CONNECT(FALSE) - disconnected." << endl
  << endl
  << "Examples:" << endl
  << "  " << pProgPath << " --use-driver=tcp 1111 222.22.22.22:2222" << endl
  << "    - listen TCP port 1111 and on incoming connection connect to" << endl
  << "      222.22.22.22:2222, receive data from 1111 and send it to" << endl
  << "      222.22.22.22:2222, receive data from 222.22.22.22:2222 and send it to" << endl
  << "      1111, on disconnecting any connection disconnect paired connection." << endl
  << "  " << pProgPath << " --use-driver=tcp *111.11.11.11:1111 *222.22.22.22:2222" << endl
  << "    - connect to 111.11.11.11:1111 and connect to 222.22.22.22:2222," << endl
  << "      receive data from 111.11.11.11:1111 and send it to 222.22.22.22:2222," << endl
  << "      receive data from 222.22.22.22:2222 and send it to 111.11.11.11:1111," << endl
  << "      on disconnecting any connection reconnect it." << endl
  << "  " << pProgPath << " --route=All:All --use-driver=tcp *1111 *1111 *1111" << endl
  << "    - up to 3 clients can connect to port 1111 and talk each others." << endl
  << "  " << pProgPath << " --load=,,_END_" << endl
  << "      COM1" << endl
  << "      COM2" << endl
  << "      --use-driver=tcp" << endl
  << "      *1111" << endl
  << "      --bi-route=0:2" << endl
  << "      *1111" << endl
  << "      --bi-route=1:3" << endl
  << "      !1111/-1" << endl
  << "      _END_" << endl
  << "    - up to 2 clients can connect to COM1 or COM2 via port 1111." << endl
  << "      The third client will be rejected." << endl
  << "  " << pProgPath << " --load=,,_END_" << endl
  << "      COM1" << endl
  << "      COM2" << endl
  << "      --use-driver=tcp" << endl
  << "      *1111" << endl
  << "      --bi-route=0:2" << endl
  << "      *1111" << endl
  << "      --bi-route=1:3" << endl
  << "      1111/-1" << endl
  << "      --bi-route=5:4" << endl
  << "      127.0.0.1:2222" << endl
  << "      _END_" << endl
  << "    - up to 2 clients can connect to COM1 or COM2 via port 1111." << endl
  << "      The third client will be routed to 127.0.0.1:2222." << endl
  ;
}