private void ReadConnectResult()
 {
     using (var reader = new EndianBinaryReader(EndianBitConverter.Big, new MemoryStream(incomingBuffer), Encoding.UTF8))
     {
         BinaryInputArchive bbia = BinaryInputArchive.GetArchive(reader);
         ConnectResponse conRsp = new ConnectResponse();
         conRsp.Deserialize(bbia, "connect");
         negotiatedSessionTimeout = conRsp.TimeOut;
         if (negotiatedSessionTimeout <= 0)
         {
             zooKeeper.State = ZooKeeper.States.CLOSED;
             conn.consumer.QueueEvent(new WatchedEvent(KeeperState.Expired, EventType.None, null));
             throw new SessionExpiredException(string.Format("Unable to reconnect to ZooKeeper service, session 0x{0:X} has expired", conn.SessionId));
         }
         conn.readTimeout = new TimeSpan(0, 0, 0, 0, negotiatedSessionTimeout*2/3);
         conn.connectTimeout = new TimeSpan(0, 0, 0, negotiatedSessionTimeout/conn.ServerAddressCount);
         conn.SessionId = conRsp.SessionId;
         conn.SessionPassword = conRsp.Passwd;
         zooKeeper.State = ZooKeeper.States.CONNECTED;
         LOG.Info(string.Format("Session establishment complete on server {0:X}, negotiated timeout = {1}", conn.SessionId, negotiatedSessionTimeout));
         conn.consumer.QueueEvent(new WatchedEvent(KeeperState.SyncConnected, EventType.None, null));
     }
 }