Net::VNC - A simple VNC client


  use Net::VNC;

  my $vnc = Net::VNC->new({hostname => $hostname, password => $password});

  print $vnc->name . ": " . $vnc->width . ' x ' . $vnc->height . "\n";

  my $image = $vnc->capture;


Virtual Network Computing (VNC) is a desktop sharing system which uses the RFB (Remote FrameBuffer) protocol to remotely control another computer. This module acts as a VNC client and communicates to a VNC server using the RFB protocol, allowing you to capture the screen of the remote computer.

This module dies upon connection errors (with a timeout of 15 seconds) and protocol errors.

This implementation is based largely on the RFB Protocol Specification, That document has an error in the DES encryption description, which is clarified via



The constructor. Given a hostname and a password returns a Net::VNC object:

  my $vnc = Net::VNC->new({hostname => $hostname, password => $password});

Optionally, you can also specify a port, which defaults to 5900.


Logs into the remote computer:



Returns the name of the remote computer:

  print $vnc->name . ": " . $vnc->width . ' x ' . $vnc->height . "\n";


Returns the width of the remote screen:

  print $vnc->name . ": " . $vnc->width . ' x ' . $vnc->height . "\n";


Returns the height of the remote screen:

  print $vnc->name . ": " . $vnc->width . ' x ' . $vnc->height . "\n";


Captures the screen of the remote computer, returning an Image::Imlib2 object:

  my $image = $vnc->capture;

You may call capture() multiple times. Each time, the $image buffer is overwritten with the updated screen. So, to create a series of ten screen shots:

  for my $n (1..10) {
    my $filename = sprintf 'snapshot%02d.png', $n++;
    print "Wrote $filename\n";


Specify the bit depth for the screen. The supported choices are 24, 16 or 8. If unspecified, the server's default value is used. This property should be set before the call to login().


Accepts a boolean, defaults to false. Specifies whether to use more CPU-intensive algorithms to compress the VNC datastream. LAN or localhost connections may prefer to leave this false. This property should be set before the call to login().


Returns a list of encoding number/encoding name pairs. This can be used as a class method like so:

   my %encodings = Net::VNC->list_encodings();


Bit depth

We do not yet support 8-bit true-colour mode, which is commonly supported by servers but is rarely employed by clients.

Byte order

We have currently tested this package against servers with the same byte order as the client. This might break with a little-endian server/big-endian client or vice versa. We're working on tests for those latter cases. Testing and patching help would be appreciated.


We've implemented a subset of the data compression algorithms supported by most VNC servers. We hope to add more of the high-compression transfer encodings in the future.


Leon Brocard

Chris Dolan

Many thanks for Foxtons Ltd for giving Leon the opportunity to write the original version of this module.

Copyright (C) 2006, Leon Brocard

This module is free software; you can redistribute it or modify it under the same terms as Perl itself.