Handshake procedure not working correctly.
The server always waits SetPixelFormat and
SetEncodings messages. From the protocol
specification I understand this is not needed. I client
which doesn't send these, will not work. It might be best
to include them in the normal message loop, that is also
handling the mouse events etc..
Second, The SetEncodings message is ignored. But it
reads 80 bytes. If you send a shorter message for
SetEncodings and afterwards a mouse movement for
example, this message is eaten by the -receiving 80
byted code-
Code in ScrMain.cpp (str is 80 bytes):
/* Receive system info from client */
if (recv(m_sock, (char *) &spf, sizeof
(rfbSetPixelFormatMsg), 0) != sizeof
(rfbSetPixelFormatMsg)) {
return -1;
}
// The above code always waits for a SetPixel message.
// The protocol documentation states:
//"... If the client does not send a SetPixelFormat
// message then the server sends pixel values in
// its natural format... So I guess it is not needed.
if (spf.format.bitsPerPixel != si.format.bitsPerPixel ||
spf.format.depth != si.format.depth) {
MessageBox(NULL, TEXT("Client requested
unsupported format"), TEXT("Vnc server"), MB_OK);
return -1;
}
/* receive supported encoding types from client...
ignore them... this assumes that whatever is received
with this call is exactly one of those packets. It is
theoretically possible that the received data
also includes the full screen update request. This
would mean that the 'Run' function does not receive
it and the client screen stays blank....
*/
(void) recv(m_sock, (char *) str, sizeof(str), 0);
// This eats the first messages if they are send too fast
// after the SetEncodings message.
// Also I don't think the SetEncodings message should
// be mandatory.