when closing TIMEWAIT is an acceptable status.

This commit is contained in:
Kelvin Sherlock 2018-04-21 16:25:59 -04:00
parent 1380609800
commit 6ba329b50b
2 changed files with 8 additions and 5 deletions

6
main.c
View File

@ -35,7 +35,7 @@ extern pascal void InitColorTable(ColorTable) inline(0x0D04,dispatcher);
Word ResolveHost(const char *name, cvtRecPtr cvt);
int WaitForStatus(word ipid, word status);
int WaitForStatus(word ipid, word status_mask);
void display_pstr(const char *);
@ -265,7 +265,7 @@ int main(int argc, char **argv) {
TCPIPOpenTCP(ipid);
// wait for the connection to occur.
ok = WaitForStatus(ipid, TCPSESTABLISHED);
ok = WaitForStatus(ipid, 1 << TCPSESTABLISHED);
if (ok > 0) display_err(ok);
if (ok != 0) goto _exit2;
@ -347,7 +347,7 @@ _exit1:
display_cstr("\n\rClosing TCP Connection...\n\r");
TCPIPCloseTCP(ipid);
WaitForStatus(ipid, TCPSCLOSED);
WaitForStatus(ipid, (1 << TCPSCLOSED) | (1 << TCPSTIMEWAIT));
_exit2:

View File

@ -87,17 +87,20 @@ EventRecord event;
return false;
}
int WaitForStatus(word ipid, word status) {
int WaitForStatus(word ipid, word status_mask) {
static srBuffer sr;
EventRecord event;
Word err;
unsigned bits;
for(;;) {
TCPIPPoll();
err = TCPIPStatusTCP(ipid, &sr);
if (err) return err;
if (sr.srState == status) return 0;
bits = 1 << sr.srState;
if (status_mask & bits) return 0;
GetNextEvent(keyDownMask | autoKeyMask, &event);
if (event.what != keyDownEvt) continue;
if (!(event.modifiers & appleKey)) continue;