diff --git a/sim_tmxr.c b/sim_tmxr.c index 767cab96..6c3b5c40 100644 --- a/sim_tmxr.c +++ b/sim_tmxr.c @@ -1286,8 +1286,7 @@ for (i = 0; i < mp->lines; i++) { /* check each line in se snprintf (msg, sizeof (msg) - 1, "tmxr_poll_conn() - establishing outgoing connection to: %s", lp->destination); tmxr_debug_connect_line (lp, msg); lp->connecting = sim_connect_sock_ex (lp->datagram ? lp->port : NULL, lp->destination, "localhost", NULL, (lp->datagram ? SIM_SOCK_OPT_DATAGRAM : 0) | - (lp->mp->packet ? SIM_SOCK_OPT_NODELAY : 0) | - SIM_SOCK_OPT_BLOCKING); + (lp->mp->packet ? SIM_SOCK_OPT_NODELAY : 0)); } } @@ -1358,8 +1357,7 @@ if ((lp->destination) && (!lp->serport)) { sprintf (msg, "tmxr_reset_ln_ex() - connecting to %s", lp->destination); tmxr_debug_connect_line (lp, msg); lp->connecting = sim_connect_sock_ex (lp->datagram ? lp->port : NULL, lp->destination, "localhost", NULL, (lp->datagram ? SIM_SOCK_OPT_DATAGRAM : 0) | - (lp->packet ? SIM_SOCK_OPT_NODELAY : 0) | - SIM_SOCK_OPT_BLOCKING); + (lp->packet ? SIM_SOCK_OPT_NODELAY : 0)); } } tmxr_init_line (lp); /* initialize line state */ @@ -3078,8 +3076,7 @@ while (*tptr) { return sim_messagef (SCPE_ARG, "Missing listen port for Datagram socket\n"); } sock = sim_connect_sock_ex (datagram ? listen : NULL, hostport, "localhost", NULL, (datagram ? SIM_SOCK_OPT_DATAGRAM : 0) | - (packet ? SIM_SOCK_OPT_NODELAY : 0) | - SIM_SOCK_OPT_BLOCKING); + (packet ? SIM_SOCK_OPT_NODELAY : 0)); if (sock != INVALID_SOCKET) { _mux_detach_line (lp, FALSE, TRUE); lp->destination = (char *)malloc(1+strlen(hostport)); @@ -5455,19 +5452,28 @@ if ((dptr) && (dbits & dptr->dctrl)) { t_stat tmxr_sock_test (DEVICE *dptr) { -char cmd[CBUFSIZE]; +char cmd[CBUFSIZE], host[CBUFSIZE], port[CBUFSIZE]; int line; TMXR *tmxr; TMLN *ln; +int32 tmp1, tmp2; t_stat stat = SCPE_OK; SOCKET sock_mux = INVALID_SOCKET; SOCKET sock_line = INVALID_SOCKET; SIM_TEST_INIT; sim_printf ("Testing %s:\n", dptr->name); +SIM_TEST(sim_parse_addr ("", NULL, 0, "localhost", NULL, 0, "1234", NULL) != -1); +SIM_TEST(sim_parse_addr ("", host, 0, "localhost", NULL, 0, "1234", NULL) != -1); +SIM_TEST(sim_parse_addr ("", host, sizeof(host), "localhost", port, 0, "1234", NULL) != -1); +SIM_TEST((sim_parse_addr ("", host, sizeof(host), "localhost", port, sizeof(port), "1234", NULL) == -1) || (strcmp(host, "localhost")) || (strcmp(port,"1234"))); +SIM_TEST((sim_parse_addr ("localhost:6666", host, sizeof(host), "localhost", port, sizeof(port), "1234", NULL) == -1) || (strcmp(host, "localhost")) || (strcmp(port,"6666"))); +SIM_TEST(sim_parse_addr ("localhost:66666", host, sizeof(host), "localhost", port, sizeof(port), "1234", NULL) != -1); +SIM_TEST((sim_parse_addr ("localhost:telnet", host, sizeof(host), "localhost", port, sizeof(port), "1234", NULL) == -1) || (strcmp(host, "localhost")) || (strcmp(port,"telnet"))); +SIM_TEST((sim_parse_addr ("telnet", host, sizeof(host), "localhost", port, sizeof(port), "1234", NULL) == -1) || (strcmp(host, "localhost")) || (strcmp(port,"telnet"))); dptr->dctrl = 0xFFFFFFFF; dptr->dctrl &= ~TMXR_DBG_TRC; -sprintf (cmd, "%s -u localhost:65500", dptr->name); +sprintf (cmd, "%s -u localhost:65500;notelnet", dptr->name); SIM_TEST(attach_cmd (0, cmd)); tmxr = (TMXR *)dptr->units->tmxr; ln = &tmxr->ldsc[tmxr->lines - 1]; @@ -5477,13 +5483,14 @@ if (tmxr->lines > 1) { for (line=0; line < tmxr->lines; line++) tmxr->ldsc[line].modem_control = FALSE; snprintf (cmd + strlen (cmd), sizeof (cmd) - strlen (cmd), ",Line=%d,localhost:65501", tmxr->lines - 1); + snprintf (cmd + strlen (cmd), sizeof (cmd) - strlen (cmd), ",Line=0,connect=localhost:65500"); SIM_TEST(attach_cmd (0, cmd)); sock_line = sim_connect_sock_ex (NULL, "localhost:65501", NULL, NULL, 0); sim_os_ms_sleep (100); - SIM_TEST((tmxr_poll_conn (tmxr) == tmxr->lines - 1) ? SCPE_OK : SCPE_IERR); + SIM_TEST((((tmp1 = tmxr_poll_conn (tmxr)) == tmxr->lines - 1) || (tmp1 == 1)) ? SCPE_OK : SCPE_IERR); sock_mux = sim_connect_sock ("", "localhost", "65500"); sim_os_ms_sleep (100); - SIM_TEST((tmxr_poll_conn (tmxr) == 0) ? SCPE_OK : SCPE_IERR); + SIM_TEST(((tmp2 = tmxr_poll_conn (tmxr)) == 0) || (tmp2 == 2) ? SCPE_OK : SCPE_IERR); show_cmd (0, "MUX"); sim_close_sock (sock_mux); sock_mux = INVALID_SOCKET;