X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/8ccc75b0d2187cd9e35913749de0ed00e9ef5931..d162e8da21fa24a45df2de04c75d278c43cc0d5d:/raw.c diff --git a/raw.c b/raw.c index cf4eaee1..b0c8370d 100644 --- a/raw.c +++ b/raw.c @@ -1,7 +1,13 @@ #include #include #include +#ifndef AUTO_WINSOCK +#ifdef WINSOCK_TWO +#include +#else #include +#endif +#endif #include "putty.h" @@ -131,6 +137,11 @@ static char *raw_init (HWND hwnd, char *host, int port, char **realhost) { default: return "WSAAsyncSelect(): unknown error"; } + /* + * We have no pre-session phase. + */ + begin_session(); + return NULL; } @@ -149,8 +160,11 @@ static int raw_msg (WPARAM wParam, LPARAM lParam) { * the queue; so it's possible that we can get here even with s * invalid. If so, we return 1 and don't worry about it. */ - if (s == INVALID_SOCKET) + if (s == INVALID_SOCKET) { + closesocket(s); + s = INVALID_SOCKET; return 1; + } if (WSAGETSELECTERROR(lParam) != 0) return -WSAGETSELECTERROR(lParam); @@ -161,8 +175,11 @@ static int raw_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; @@ -226,5 +243,6 @@ Backend raw_backend = { raw_size, raw_special, raw_socket, - raw_sendok + raw_sendok, + 1 };