summaryrefslogtreecommitdiffstats
path: root/common/rfb/SConnection.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2018-06-18 16:51:53 +0200
committerPierre Ossman <ossman@cendio.se>2018-10-26 16:47:49 +0200
commitea7ede9838ac51bab0427ecc8b46cc737497a375 (patch)
tree648c7b76ab9334004de9ced53122193042671533 /common/rfb/SConnection.cxx
parent52a2e6520a6875f6a1434af2a0653d8a32fe7cf7 (diff)
downloadtigervnc-ea7ede9838ac51bab0427ecc8b46cc737497a375.tar.gz
tigervnc-ea7ede9838ac51bab0427ecc8b46cc737497a375.zip
Move version reading/writing out of ConnParams
That object is just a container for the current state. Move the I/O to the classes already doing such stuff.
Diffstat (limited to 'common/rfb/SConnection.cxx')
-rw-r--r--common/rfb/SConnection.cxx25
1 files changed, 21 insertions, 4 deletions
diff --git a/common/rfb/SConnection.cxx b/common/rfb/SConnection.cxx
index efc26acf..846e97e4 100644
--- a/common/rfb/SConnection.cxx
+++ b/common/rfb/SConnection.cxx
@@ -80,7 +80,12 @@ void SConnection::setStreams(rdr::InStream* is_, rdr::OutStream* os_)
void SConnection::initialiseProtocol()
{
- cp.writeVersion(os);
+ char str[13];
+
+ sprintf(str, "RFB %03d.%03d\n", defaultMajorVersion, defaultMinorVersion);
+ os->writeBytes(str, 12);
+ os->flush();
+
state_ = RFBSTATE_PROTOCOL_VERSION;
}
@@ -104,13 +109,25 @@ void SConnection::processMsg()
void SConnection::processVersionMsg()
{
+ char verStr[13];
+ int majorVersion;
+ int minorVersion;
+
vlog.debug("reading protocol version");
- bool done;
- if (!cp.readVersion(is, &done)) {
+
+ if (!is->checkNoWait(12))
+ return;
+
+ is->readBytes(verStr, 12);
+ verStr[12] = '\0';
+
+ if (sscanf(verStr, "RFB %03d.%03d\n",
+ &majorVersion, &minorVersion) != 2) {
state_ = RFBSTATE_INVALID;
throw Exception("reading version failed: not an RFB client?");
}
- if (!done) return;
+
+ cp.setVersion(majorVersion, minorVersion);
vlog.info("Client needs protocol version %d.%d",
cp.majorVersion, cp.minorVersion);