*** ssl.c	Sat Dec 16 14:57:52 2000
--- ssl.c.stdin	Tue Jan 16 14:26:36 2001
***************
*** 565,570 ****
--- 565,571 ----
  
  static int transfer(SSL *ssl, int sock_fd) /* transfer data */
  {
+     int sock_fd_write;
      fd_set rd_set, wr_set;
      int num, fdno, ssl_fd, ssl_bytes, sock_bytes, retval;
      char sock_buff[BUFFSIZE], ssl_buff[BUFFSIZE];
***************
*** 583,593 ****
--- 584,597 ----
      ssl_open=1;
      sock_bytes=0;
      ssl_bytes=0;
+     sock_fd_write = (sock_fd == fileno(stdin) ? fileno(stdout) : sock_fd);
  
  #if defined FIONBIO && defined USE_NBIO
      l=1; /* ON */
      if(ioctlsocket(sock_fd, FIONBIO, &l)<0)
          sockerror("ioctlsocket (sock)"); /* non-critical */
+     if(ioctlsocket(sock_fd_write, FIONBIO, &l)<0)
+         sockerror("ioctlsocket (sock)"); /* non-critical */                                 
      if(ioctlsocket(ssl_fd, FIONBIO, &l)<0)
          sockerror("ioctlsocket (ssl)"); /* non-critical */
      log(LOG_DEBUG, "Sockets set to non-blocking mode");
***************
*** 613,619 ****
          FD_ZERO(&wr_set);
  
          if(sock_open && ssl_ptr) /* can write to socket */
!             FD_SET(sock_fd, &wr_set);
  
          if (   ssl_open
              && (   (sock_ptr) /* can write to SSL */
--- 617,623 ----
          FD_ZERO(&wr_set);
  
          if(sock_open && ssl_ptr) /* can write to socket */
!             FD_SET(sock_fd_write, &wr_set);
  
          if (   ssl_open
              && (   (sock_ptr) /* can write to SSL */
***************
*** 635,642 ****
  
          check_SSL_pending = 0;
  
!         if(sock_open && FD_ISSET(sock_fd, &wr_set)) {
!             num=writesocket(sock_fd, ssl_buff, ssl_ptr);
              if(num<0) {
                  sockerror("write");
                  goto error;
--- 639,646 ----
  
          check_SSL_pending = 0;
  
!         if(sock_open && FD_ISSET(sock_fd_write, &wr_set)) {
!             num=writesocket(sock_fd_write, ssl_buff, ssl_ptr);
              if(num<0) {
                  sockerror("write");
                  goto error;
***************
*** 764,769 ****
--- 768,775 ----
      l=0; /* OFF */
      if(ioctlsocket(sock_fd, FIONBIO, &l)<0)
          sockerror("ioctlsocket (sock)"); /* non-critical */
+     if(ioctlsocket(sock_fd_write, FIONBIO, &l)<0)
+         sockerror("ioctlsocket (sock)"); /* non-critical */                                 
      if(ioctlsocket(ssl_fd, FIONBIO, &l)<0)
          sockerror("ioctlsocket (ssl)"); /* non-critical */
  #endif
