How to determine if user connected to UltraVNC server

By | September 7, 2012

To check if user connected to UltraVNC server you should enable logging in ultravnc.ini:


Then you just need to read log file and check if this file contains string “vnchttpconnect.cpp : HTTP client connected” for http connections and “vncclient.cpp : client connected” for VNC client connections.

C# example that wait for incoming http or vnc connection during localTimeout period:

bool isUserConnected = false;
var startTime = DateTime.Now;
localTimeout = 10000;
  using (var fileStream = new FileStream("C:\\ultravnc\\WinVNC.log", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
    using (var streamReader = new StreamReader(fileStream))
      string text = streamReader.ReadToEnd();
      isUserConnected = text.Contains("vnchttpconnect.cpp : HTTP client connected") || text.Contains("vncclient.cpp : client connected");
  DateTime current = DateTime.Now;
  if ((current - startTime).TotalSeconds >= localTimeout)
    isUserConnected = false;
while (!isUserConnected);

Leave a Reply

Your email address will not be published. Required fields are marked *