Use WM_SETREDRAW to disable incremental updates while the config box
[u/mdw/putty] / winnet.c
index ee2fc3a..1a80a80 100644 (file)
--- a/winnet.c
+++ b/winnet.c
@@ -570,7 +570,7 @@ Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
     return (Socket) ret;
 }
 
-Socket sk_newlistenner(int port, Plug plug)
+Socket sk_newlistener(int port, Plug plug, int local_host_only)
 {
     static struct socket_function_table fn_table = {
        sk_tcp_plug,
@@ -627,13 +627,19 @@ Socket sk_newlistenner(int port, Plug plug)
        if (addr->family == AF_INET6) {
            memset(&a6, 0, sizeof(a6));
            a6.sin6_family = AF_INET6;
-/*a6.sin6_addr      = in6addr_any; *//* == 0 */
+           if (local_host_only)
+               a6.sin6_addr = in6addr_loopback;
+           else
+               a6.sin6_addr = in6addr_any;
            a6.sin6_port = htons(port);
        } else
 #endif
        {
            a.sin_family = AF_INET;
-           a.sin_addr.s_addr = htonl(INADDR_ANY);
+           if (local_host_only)
+               a.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+           else
+               a.sin_addr.s_addr = htonl(INADDR_ANY);
            a.sin_port = htons((short)port);
        }
 #ifdef IPV6
@@ -712,14 +718,15 @@ void try_send(Actual_Socket s)
        noise_ultralight(nsent);
        if (nsent <= 0) {
            err = (nsent < 0 ? WSAGetLastError() : 0);
-           if ((err == 0 && nsent < 0) || err == WSAEWOULDBLOCK) {
+           if ((err < WSABASEERR && nsent < 0) || err == WSAEWOULDBLOCK) {
                /*
                 * Perfectly normal: we've sent all we can for the moment.
                 * 
-                * (Apparently some WinSocks can return <0 but
-                * leave no error indication - WSAGetLastError() is
-                * called but returns zero - so we check that case
-                * and treat it just like WSAEWOULDBLOCK.)
+                * (Some WinSock send() implementations can return
+                * <0 but leave no sensible error indication -
+                * WSAGetLastError() is called but returns zero or
+                * a small number - so we check that case and treat
+                * it just like WSAEWOULDBLOCK.)
                 */
                s->writable = FALSE;
                return;
@@ -909,23 +916,23 @@ int select_result(WPARAM wParam, LPARAM lParam)
        return open;
        case FD_ACCEPT:
        {
-               struct sockaddr isa;
-               int addrlen = sizeof(struct sockaddr);
-               SOCKET t;  /* socket of connection */
-
-               memset(&isa, 0, sizeof(struct sockaddr));
-               err = 0;
-               t = accept(s->s,&isa,&addrlen);
-               if (t == INVALID_SOCKET)
-                               {
-                                       err = WSAGetLastError();
-                                       if (err == WSATRY_AGAIN)
-                                               break;
-                               }
-
-               if (plug_accepting(s->plug, &isa, (void*)t)) {
-                       closesocket(t); // denied or error
-               }
+           struct sockaddr isa;
+           int addrlen = sizeof(struct sockaddr);
+           SOCKET t;  /* socket of connection */
+
+           memset(&isa, 0, sizeof(struct sockaddr));
+           err = 0;
+           t = accept(s->s,&isa,&addrlen);
+           if (t == INVALID_SOCKET)
+           {
+               err = WSAGetLastError();
+               if (err == WSATRY_AGAIN)
+                   break;
+           }
+
+           if (plug_accepting(s->plug, (void*)t)) {
+               closesocket(t);        /* denied or error */
+           }
        }
     }