diff --git a/PDP11/pdp11_dz.c b/PDP11/pdp11_dz.c index efeb5998..e09aa377 100644 --- a/PDP11/pdp11_dz.c +++ b/PDP11/pdp11_dz.c @@ -242,6 +242,7 @@ TMXR dz_desc = { DZ_MUXES * DZ_LINES, 0, 0, NULL }; /* mux descriptor */ #define DBG_XMT TMXR_DBG_XMT /* display Transmitted Data */ #define DBG_RCV TMXR_DBG_RCV /* display Received Data */ #define DBG_MDM TMXR_DBG_MDM /* display Modem Signals */ +#define DBG_CON TMXR_DBG_CON /* display connection activities */ #define DBG_TRC TMXR_DBG_TRC /* display trace routine calls */ #define DBG_ASY TMXR_DBG_ASY /* display Asynchronous Activities */ @@ -251,6 +252,7 @@ DEBTAB dz_debug[] = { {"XMT", DBG_XMT}, {"RCV", DBG_RCV}, {"MDM", DBG_MDM}, + {"CON", DBG_CON}, {"TRC", DBG_TRC}, {"ASY", DBG_ASY}, {0} diff --git a/PDP11/pdp11_vh.c b/PDP11/pdp11_vh.c index 13e30131..b2172987 100644 --- a/PDP11/pdp11_vh.c +++ b/PDP11/pdp11_vh.c @@ -305,6 +305,8 @@ static TMLX vh_parm[VH_MUXES * VH_LINES_ALLOC] = { { 0 } }; #define DBG_TRC TMXR_DBG_TRC /* trace routine calls */ #define DBG_XMT TMXR_DBG_XMT /* display Transmitted Data */ #define DBG_RCV TMXR_DBG_RCV /* display Received Data */ +#define DBG_MDM TMXR_DBG_MDM /* display Modem Signals */ +#define DBG_CON TMXR_DBG_CON /* display connection activities */ #define DBG_TRC TMXR_DBG_TRC /* display trace routine calls */ #define DBG_ASY TMXR_DBG_ASY /* display Asynchronous Activities */ @@ -314,6 +316,8 @@ DEBTAB vh_debug[] = { {"TRC", DBG_TRC}, {"XMT", DBG_XMT}, {"RCV", DBG_RCV}, + {"MDM", DBG_MDM}, + {"CON", DBG_CON}, {"TRC", DBG_TRC}, {"ASY", DBG_ASY}, {0} diff --git a/sim_sock.c b/sim_sock.c index 111e29c3..5f3b78ce 100644 --- a/sim_sock.c +++ b/sim_sock.c @@ -939,6 +939,10 @@ if (rbytes == SOCKET_ERROR) { err = WSAGetLastError (); if (err == WSAEWOULDBLOCK) /* no data */ return 0; +#if defined(EAGAIN) + if (err == EAGAIN) /* no data */ + return 0; +#endif if ((err != WSAETIMEDOUT) && /* expected errors after a connect failure */ (err != WSAEHOSTUNREACH) && (err != WSAECONNREFUSED)) diff --git a/sim_tmxr.c b/sim_tmxr.c index 90ddcff6..27fa6acb 100644 --- a/sim_tmxr.c +++ b/sim_tmxr.c @@ -816,7 +816,7 @@ if (mp->master) { if (newsock != INVALID_SOCKET) { /* got a live one? */ sprintf (msg, "tmxr_poll_conn() - Connection from %s", address); - tmxr_debug_trace (mp, msg); + tmxr_debug_connect (mp, msg); op = mp->lnorder; /* get line connection order list pointer */ i = mp->lines; /* play it safe in case lines == 0 */ ++mp->sessions; /* count the new session */ @@ -836,7 +836,7 @@ if (mp->master) { if (i >= mp->lines) { /* all busy? */ tmxr_msg (newsock, "All connections busy\r\n"); - tmxr_debug_trace (mp, "tmxr_poll_conn() - All connections busy"); + tmxr_debug_connect (mp, "tmxr_poll_conn() - All connections busy"); sim_close_sock (newsock, 0); free (address); } @@ -872,8 +872,12 @@ for (i = 0; i < mp->lines; i++) { /* check each line in se lp->ipad = realloc (lp->ipad, 1+strlen (lp->destination)); strcpy (lp->ipad, lp->destination); lp->cnms = sim_os_msec (); + sprintf (msg, "tmxr_poll_conn() - Line Connection to %s established", lp->destination); + tmxr_debug_connect_line (lp, msg); break; case -1: /* failed connection */ + sprintf (msg, "tmxr_poll_conn() - Line Connection to %s failed", lp->destination); + tmxr_debug_connect_line (lp, msg); tmxr_reset_ln (lp); /* retry */ break; } @@ -887,7 +891,7 @@ for (i = 0; i < mp->lines; i++) { /* check each line in se if (newsock != INVALID_SOCKET) { /* got a live one? */ sprintf (msg, "tmxr_poll_conn() - Line Connection from %s", address); - tmxr_debug_trace_line (lp, msg); + tmxr_debug_connect_line (lp, msg); ++mp->sessions; /* count the new session */ if (lp->destination) { /* Virtual Null Modem Cable? */ @@ -896,12 +900,14 @@ for (i = 0; i < mp->lines; i++) { /* check each line in se if (sim_parse_addr (lp->destination, host, sizeof(host), NULL, NULL, 0, NULL, address)) { tmxr_msg (newsock, "Rejecting connection from unexpected source\r\n"); sprintf (msg, "tmxr_poll_conn() - Rejecting line connection from: %s, Expected: %s", address, host); - tmxr_debug_trace_line (lp, msg); + tmxr_debug_connect_line (lp, msg); sim_close_sock (newsock, 0); free (address); continue; /* Move on to next line */ } if (lp->connecting) { + sprintf (msg, "tmxr_poll_conn() - aborting outgoing line connection attempt to: %s", lp->destination); + tmxr_debug_connect_line (lp, msg); sim_close_sock (lp->connecting, 0); /* abort our as yet unconnnected socket */ lp->connecting = 0; } @@ -921,7 +927,7 @@ for (i = 0; i < mp->lines; i++) { /* check each line in se } else { tmxr_msg (newsock, "Line connection busy\r\n"); - tmxr_debug_trace_line (lp, "tmxr_poll_conn() - Line connection busy"); + tmxr_debug_connect_line (lp, "tmxr_poll_conn() - Line connection busy"); sim_close_sock (newsock, 0); free (address); } @@ -939,8 +945,11 @@ for (i = 0; i < mp->lines; i++) { /* check each line in se /* Check for needed outgoing connection initiation */ if (lp->destination && (!lp->sock) && (!lp->connecting) && (!lp->serport) && - (!mp->modem_control || (lp->modembits & TMXR_MDM_DTR))) + (!mp->modem_control || (lp->modembits & TMXR_MDM_DTR))) { + sprintf (msg, "tmxr_poll_conn() - establishing outgoing connection to: %s", lp->destination); + tmxr_debug_connect_line (lp, msg); lp->connecting = sim_connect_sock (lp->destination, "localhost", NULL); + } } @@ -958,6 +967,8 @@ return -1; /* no new connections ma static t_stat tmxr_reset_ln_ex (TMLN *lp, t_bool closeserial) { +char msg[512]; + tmxr_debug_trace_line (lp, "tmxr_reset_ln_ex)"); if (lp->txlog) @@ -965,6 +976,9 @@ if (lp->txlog) tmxr_send_buffered_data (lp); /* send any buffered data */ +sprintf (msg, "tmxr_reset_ln_ex(%s)", closeserial ? "TRUE" : "FALSE"); +tmxr_debug_connect_line (lp, msg); + if (lp->serport) { if (closeserial) { sim_close_serial (lp->serport); @@ -995,10 +1009,15 @@ else /* Telnet connection */ free(lp->ipad); lp->ipad = NULL; if ((lp->destination) && (!lp->serport)) { - if (lp->connecting) + if (lp->connecting) { sim_close_sock (lp->connecting, 0); - if ((!lp->mp->modem_control) || (lp->modembits & TMXR_MDM_DTR)) + lp->connecting = 0; + } + if ((!lp->mp->modem_control) || (lp->modembits & TMXR_MDM_DTR)) { + sprintf (msg, "tmxr_reset_ln_ex() - connecting to %s", lp->destination); + tmxr_debug_connect_line (lp, msg); lp->connecting = sim_connect_sock (lp->destination, "localhost", NULL); + } } tmxr_init_line (lp); /* initialize line state */ /* Revise the unit's connect string to reflect the current attachments */ @@ -1012,6 +1031,7 @@ return SCPE_OK; t_stat tmxr_close_ln (TMLN *lp) { tmxr_debug_trace_line (lp, "tmxr_close_ln()"); +tmxr_debug_connect_line (lp, "tmxr_close_ln()"); return tmxr_reset_ln_ex (lp, TRUE); } @@ -1144,8 +1164,13 @@ if (lp->mp && lp->mp->modem_control) { /* This API ONLY works on mo else { if ((lp->destination) && /* Virtual Null Modem Cable */ ((bits_to_set ^ before_modem_bits) & /* and DTR being Raised */ - TMXR_MDM_DTR)) + TMXR_MDM_DTR)) { + char msg[512]; + + sprintf (msg, "tmxr_set_get_modem_bits() - establishing outgoing connection to: %s", lp->destination); + tmxr_debug_connect_line (lp, msg); lp->connecting = sim_connect_sock (lp->destination, "localhost", NULL); + } } } return SCPE_OK; diff --git a/sim_tmxr.h b/sim_tmxr.h index 147234fc..d1c26a08 100644 --- a/sim_tmxr.h +++ b/sim_tmxr.h @@ -69,8 +69,9 @@ typedef int SERHANDLE; #define TMXR_DBG_XMT 0x010000 /* Debug Transmit Data */ #define TMXR_DBG_RCV 0x020000 /* Debug Received Data */ #define TMXR_DBG_MDM 0x040000 /* Debug Modem Signals */ -#define TMXR_DBG_ASY 0x080000 /* Debug Asynchronous Activities */ -#define TMXR_DBG_TRC 0x100000 /* Debug trace routine calls */ +#define TMXR_DBG_CON 0x080000 /* Debug Connection Activities */ +#define TMXR_DBG_ASY 0x100000 /* Debug Asynchronous Activities */ +#define TMXR_DBG_TRC 0x200000 /* Debug trace routine calls */ /* Modem Control Bits */ @@ -202,6 +203,8 @@ extern FILE *sim_deb; /* debug file */ #define tmxr_debug(dbits, lp, msg, buf, bufsize) if (sim_deb && (lp)->mp->dptr && ((dbits) & (lp)->mp->dptr->dctrl)) _tmxr_debug (dbits, lp, msg, buf, bufsize); else (void)0 #define tmxr_debug_trace(mp, msg) if (sim_deb && (mp)->dptr && (TMXR_DBG_TRC & (mp)->dptr->dctrl)) sim_debug (TMXR_DBG_TRC, mp->dptr, "%s\n", (msg)); else (void)0 #define tmxr_debug_trace_line(lp, msg) if (sim_deb && (lp)->mp && (lp)->mp->dptr && (TMXR_DBG_TRC & (lp)->mp->dptr->dctrl)) sim_debug (TMXR_DBG_TRC, (lp)->mp->dptr, "%s\n", (msg)); else (void)0 +#define tmxr_debug_connect(mp, msg) if (sim_deb && (mp)->dptr && (TMXR_DBG_CON & (mp)->dptr->dctrl)) sim_debug (TMXR_DBG_CON, mp->dptr, "%s\n", (msg)); else (void)0 +#define tmxr_debug_connect_line(lp, msg) if (sim_deb && (lp)->mp && (lp)->mp->dptr && (TMXR_DBG_CON & (lp)->mp->dptr->dctrl)) sim_debug (TMXR_DBG_CON, (lp)->mp->dptr, "%s\n", (msg)); else (void)0 #if defined(SIM_ASYNCH_IO) && defined(SIM_ASYNCH_MUX) #define tmxr_attach(mp, uptr, cptr) tmxr_attach_ex(mp, uptr, cptr, TRUE)