From 7764212442411b88d673506cae98a271c0bba402 Mon Sep 17 00:00:00 2001 From: ben Date: Sat, 11 Jan 2003 17:31:59 +0000 Subject: [PATCH] When polling MacTCP connections, check the connection state and if the far end has sent a FIN pass that up to the plug. TODO: handle less graceful connection closures. git-svn-id: svn://svn.tartarus.org/sgt/putty@2544 cda61777-01e9-0310-a592-d414129be87e --- mac/mtcpnet.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/mac/mtcpnet.c b/mac/mtcpnet.c index 60dd84e3..bd630878 100644 --- a/mac/mtcpnet.c +++ b/mac/mtcpnet.c @@ -142,6 +142,19 @@ enum { uppAddrToStrProcInfo = kCStackBased /* End of AddressXlation.h bits */ +/* TCP connection states, mysteriously missing from */ +#define TCPS_CLOSED 0 +#define TCPS_LISTEN 2 +#define TCPS_SYN_RECEIVED 4 +#define TCPS_SYN_SENT 6 +#define TCPS_ESTABLISHED 8 +#define TCPS_FIN_WAIT_1 10 +#define TCPS_FIN_WAIT_2 12 +#define TCPS_CLOSE_WAIT 14 +#define TCPS_CLOSING 16 +#define TCPS_LAST_ACK 18 +#define TCPS_TIME_WAIT 20 + struct Socket_tag { struct socket_function_table *fn; /* the above variable absolutely *must* be the first in this structure */ @@ -606,8 +619,12 @@ void mactcp_poll(void) if (pb.csParam.status.amtUnreadData == 0) break; mactcp_recv(s, pb.csParam.status.amtUnreadData); - /* Should check connectionState in case remote has closed */ } while (TRUE); + switch (pb.csParam.status.connectionState) { + case TCPS_CLOSE_WAIT: + /* Remote end has sent us a FIN */ + plug_closing(s->plug, NULL, 0, 0); + } next_socket: ; } -- 2.11.0