Oops. Better make sure that FP only gets allocated
if we really need it... Here's a corrected patch.
Sorry...
-- Joe
"Joseph A. Knapka" wrote:
>
> Jens Wagner wrote:
> >
> > "Joseph A. Knapka" schrieb:
> >
> > > ...
> > > It would be nice if the server could serve the Java applet via
> > > HTTP on the RFB port, but unfortunately the RFB handshake
> > > begins with the server writing the RFB protocol version,
> > > whereas the HTTP handshake begins with the client sending an
> > > HTTP request -- which means the server can't decide what
> > > to do based on the client's request. Darn.
> > >
> > > -- Joe
> >
> > Nice idea. Maybe the server could wait one or two seconds for a client request. If
>there's an http request within time the server will handle it as an http server, else
>it will start the rfb hanshake.
> >
> > - jens
>
> The attached small patch seems to work fine for Xvnc. It works
> exactly as Jens suggests. Of course HTTP connections to 58xx
> work as usual. I've tested with Netscape 4.76 and IE4. I'll
> tackle the WinVNC server in a day or two unless someone
> beats me to it.
-- Joe Knapka
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 0;
+ }
+
+ 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)) {
---------------------------------------------------------------------
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
---------------------------------------------------------------------