"Joseph A. Knapka" wrote:

> > > > It would be nice if the server could serve the Java applet via
> > > > HTTP on the RFB port, but unfortunately the RFB handshake

One more fix (last one, I promise): in the unlikely event that
the fdopen() call fails, we should not then attempt to use the
closed socket for RFB...

-- Joe

diff -C 3 -r vnc_unixsrc/Xvnc/programs/Xserver/hw/vnc/httpd.c
vnc_patched/Xvnc/programs/Xserver/hw/vnc/httpd.c
*** vnc_unixsrc/Xvnc/programs/Xserver/hw/vnc/httpd.c    Thu Apr 29
05:10:54 1999
--- vnc_patched/Xvnc/programs/Xserver/hw/vnc/httpd.c    Tue Dec  5
23:26:48 2000
***************
*** 158,163 ****
--- 158,199 ----


  /*
+  * maybeHandleHTTPRequest is called when a client connects to the RFB
+  * port. If the client sends a get request within 2 seconds, we handle
+  * it here. Otherwise we go ahead and start the RFB handshake.
+  */
+ int maybeHandleHTTPRequest(int rfbSock)
+ {
+   fd_set fds;
+   int nfds;
+   struct timeval tv;
+   httpSock = rfbSock; /* For httpProcessInput's benefit */
+
+   FD_ZERO(&fds);
+   FD_SET(rfbSock,&fds);
+   tv.tv_sec = 2;
+   tv.tv_usec = 0;
+   nfds = select(rfbSock + 1, &fds, NULL, NULL, &tv);
+   if (nfds == 0) {
+     httpSock = -1;
+     return 0;
+   }
+
+   /* Client is sending a GET request. */
+   if ((httpFP = fdopen(rfbSock, "r+")) == NULL) {
+     rfbLogPerror("maybeHandleHTTPRequest: fdopen");
+     close(rfbSock);
+     httpSock = -1;
+     return 1; /* OK, we tried. Caller should give up now. */
+   }
+
+   httpProcessInput();
+
+   /* Tell caller we processed an HTTP request. */
+   return 1;
+ }
+
+ /*
   * httpProcessInput is called when input is received on the HTTP
socket.
   */

diff -C 3 -r vnc_unixsrc/Xvnc/programs/Xserver/hw/vnc/sockets.c
vnc_patched/Xvnc/programs/Xserver/hw/vnc/sockets.c
*** vnc_unixsrc/Xvnc/programs/Xserver/hw/vnc/sockets.c  Wed Oct 25
09:42:22 2000
--- vnc_patched/Xvnc/programs/Xserver/hw/vnc/sockets.c  Tue Dec  5
21:41:54 2000
***************
*** 49,54 ****
--- 49,58 ----

  #include "rfb.h"

+ /* Allow server to serve Java applet over RFB socket. This
+    function is defined in httpd.c.
+ */
+ int maybeHandleHTTPRequest(int sock);

  int rfbMaxClientWait = 20000; /* time (ms) after which we decide
client has
                                   gone away - needed to stop us hanging
*/
***************
*** 194,199 ****
--- 198,215 ----
        fprintf(stderr,"\n");
        rfbLog("Got connection from client %s\n",
inet_ntoa(addr.sin_addr));

+       /* If the client wants us to serve the Java applet, do that.
+          Otherwise start the RFB handshake.
+       */
+       if (maybeHandleHTTPRequest(sock)) {
+         rfbLog("Woo hoo! Served Java applet via RFB!");
+         /* The http server has served the Java applet and disconnected
+            the client. The client will reconnect to the RFB port and
+            we will carry on.
+         */
+         return;
+       }
+
        AddEnabledDevice(sock);
        FD_SET(sock, &allFds);
        maxFd = max(sock,maxFd);
***************
*** 202,208 ****

        FD_CLR(rfbListenSock, &fds);
        if (--nfds == 0)
!           return;
      }

      if ((udpSock != -1) && FD_ISSET(udpSock, &fds)) {
--- 218,224 ----

        FD_CLR(rfbListenSock, &fds);
        if (--nfds == 0)
!         return;
      }

      if ((udpSock != -1) && FD_ISSET(udpSock, &fds)) {

-- Joe Knapka
---------------------------------------------------------------------
To unsubscribe, send a message with the line: unsubscribe vnc-list
to [EMAIL PROTECTED]
See also: http://www.uk.research.att.com/vnc/intouch.html
---------------------------------------------------------------------

Reply via email to