X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/8ccc75b0d2187cd9e35913749de0ed00e9ef5931..fe50e8140a2dbb3ba357a0ab777f34e07d568c23:/raw.c diff --git a/raw.c b/raw.c index cf4eaee1..3f82d7ad 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" @@ -48,8 +54,7 @@ static void s_write (void *buf, int len) { } static void c_write (char *buf, int len) { - while (len--) - c_write1(*buf++); + from_backend(0, buf, len); } /* @@ -131,6 +136,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 +159,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 +174,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 +242,6 @@ Backend raw_backend = { raw_size, raw_special, raw_socket, - raw_sendok + raw_sendok, + 1 };