NAME
   Linux::NBD::Client - client (device) side of a network block device

SYNOPSIS
    use Linux::NBD::Client;

DESCRIPTION
   WARNING: I talked to the author of the nbd driver because nbd is so
   extremely racy (right now, stopping it often causes oopses, a server
   crashing also often oopses etc..).

   It turned out that he doesn't care at all and nbd is basically
   unmaintained, so YMMV when using this module, especially when writing
   servers.

   He really should have said that on his nbd pages ;[.

   OTOH, it works relatively reliable when you don't stop the servers, so
   watch out and keep your fingers crossed.

METHODS
   $client = new Linux::NBD::Client [socket => $fh][, device =>
   "/dev/nbdX"], ...
       Create a new client.

       Unless "device" is given, an unused device node is looked up using
       the "device" method (this might result in an exception!).

   $client->socket ([$tcp_socket])
       Returns the current socket after setting a new one (if an argument
       is supplied). The socket *MUST* be a tcp socket. Believe me, bad
       things will happen if not.

       The special argument "undef" will try to clear the socket, if any
       was set.

   $client->device ([$new_device])
       Returns the current device node (e.g. "/dev/nbd2") after setting a
       new one if an argument is supplied.

       If the argument is "undef" it will search for an unallocated
       nbd-device and use it.

   $client->disconnect
       Tries to exit the server by sending a special disconnect message.

   $client->clear_queue
       Clears the request queue, if possible. Should be used before setting
       a new socket.

   $client->set_timeout ($timeout)
       Set the request timeout, in seconds.

   $client->set_blocksize ($blksize)
       Set the device block size in bytes, i.e. how big each block is (must
       be >512, <PAGESIZE and a power of two).

       Also rounds down the device size to be a multiple of the block size.

   $client->set_blocks ($nblocks)
       Set the device size in block units.

   $client->set_size ($bytes)
       Set the device size in octet units, will be rounded down to be a
       multiple of the block size.

   $client->run
       Closes all file descriptors except the server socket and enters the
       service loop (waits for read/write requests on the device and
       forwards them over the given socket). Only returns when somebody
       calls "disconnect" or the server is killed.

   $pid = $client->run_async
       Runs the service loop asynchronously and returns the pid of the
       newly created service process.

   $client->kill_async
       Kills any running async service. Please note that this also kills
       the socket, so you need to re-set the socket after this call.

AUTHOR
    Marc Lehmann <[email protected]>
    http://home.schmorp.de/

POD ERRORS
   Hey! The above document had some coding errors, which are explained
   below:

   Around line 258:
       =cut found outside a pod block. Skipping to next block.