X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/8ccc75b0d2187cd9e35913749de0ed00e9ef5931..4d331a77f20f321f867f5907e2ffc06249378881:/telnet.c diff --git a/telnet.c b/telnet.c index 283ea5b6..6618fdf8 100644 --- a/telnet.c +++ b/telnet.c @@ -1,7 +1,13 @@ #include #include #include +#ifndef AUTO_WINSOCK +#ifdef WINSOCK_TWO +#include +#else #include +#endif +#endif #include "putty.h" @@ -583,6 +589,12 @@ static char *telnet_init (HWND hwnd, char *host, int port, char **realhost) { * Set up SYNCH state. */ in_synch = FALSE; + + /* + * We have no pre-session phase. + */ + begin_session(); + return NULL; } @@ -608,8 +620,11 @@ static int telnet_msg (WPARAM wParam, LPARAM lParam) { if (s == INVALID_SOCKET) return 1; - if (WSAGETSELECTERROR(lParam) != 0) + if (WSAGETSELECTERROR(lParam) != 0) { + closesocket(s); + s = INVALID_SOCKET; return -WSAGETSELECTERROR(lParam); + } switch (WSAGETSELECTEVENT(lParam)) { case FD_READ: @@ -625,8 +640,11 @@ static int telnet_msg (WPARAM wParam, LPARAM lParam) { ret = recv(s, buf, sizeof(buf), 0); if (ret < 0 && WSAGetLastError() == WSAEWOULDBLOCK) return 1; - if (ret < 0) /* any _other_ error */ + if (ret < 0) { /* any _other_ error */ + closesocket(s); + s = INVALID_SOCKET; return -10000-WSAGetLastError(); + } if (ret == 0) { s = INVALID_SOCKET; return 0;