NAME

Net::NetSend - Perl extension for sending Windows Popup Messages

SYNOPSIS

use Net::NetSend qw(:all);

my $target_netbios_name = "pc04";
my $source_netbios_name = "mypc";
my $target_ip = "192.168.0.1";
my $message = "Hello World!";
my $debug = 0;  

my $success = sendMsg($target_netbios_name, $source_netbios_name, $target_ip, $message, $debug);

print ($success ? "Delivery successfull\n" : "Error in delivery! \n$@\n");

DESCRIPTION

This module implements a client interface to the Windows Messenger Service, enabling a perl5 application to talk to windows machines. This is a pure Perl implementation that approximates the "net send" command on Windows.

EXPLANATION

The source netbios name may be chosen freely and does not need to match your real netbios name.

Both target netbios name and target IP are needed as there are no lookup procedures implemeted in this module yet. You're welcome to add these and send me a patch. If noone else volunteers for this task, I intend to do this myself when I've got some spare time for it.

The target IP can be a numerical IP like it is shown above or a hostname like host.domain.tld.

The message can be any arbitrary string. If it is greater than 4000 chars the message will still be delivered but truncated to 4000 chars. If you _really_ want to send more text than 4000 chars you can split your message into parts of the respective maximum of 4000 chars and call sendMsg() for all parts consecutively. In this case be sure to have a look at the CAVEATS section a few lines down this page.

Debug is intended to print more status information in case of difficulties. In general it works like a "verbose" switch. The parameter "debug" is optional and defaults to 0. It can be one or zero. Zero means "No, don't print debug messages.", one means "Yes, please print debug messages to STDOUT."

By default (debug off), sendMsg() does not print anything in case of success. In case of a failure it prints an error message.

CAVEATS

This module expects answers from the remote machine when a connection has been successfully established. If the remote machine stops responding after the connection has been established it might hang forever. You can use the alarm function to be sure this does not happen. As this situation is extremely rare you probably don't need it. But if you intend to send thousands of messages at once you should probably do it.

Be advised that you need a short pause (one second is more than enough) between two messages to the same machine. No pause is needed between messages to different machines.

If sendMsg() fails it will call die(). If you don't want your program to exit when sending a message to one machine fails (because you want it to try delivering the message to another machine) you have to encapsulate the call to sendMsg() in an eval statement.

EXPORT

None by default. :all exports just sendMsg()

NOTES

This module is still under development. So far, sending messages was tested from Windows XP and Linux to Windows XP as well as from Linux to Windows NT. However, it should work on any other operating system as well. Drop me a note if you encounter errors, giving the exact circumstances of the failure and a listing of the output with debug enabled.

Maximum Message size is 4000 bytes due to a Windows limitation. For Windows 98 / 98 SE / Me / 2000 the limit should not be different.

CHANGES

new in 0.02

*

bugfix last message of multi block message

*

check MBM text packet return codes for success

    new in 0.04

    *

    check restriction of 4021 chars maximum message length

    *

    Warnings AF_INET / SOCK_STREAM eliminated

    *

    check MBM END packet return codes

    *

    extra function for error checking in SMB return packets

    *

    sendMsg now returns success/error code

    new in 0.05

    *

    abort if session request fails

    *

    set $@ if error occurs

    *

    change some global vars to local ones

    new in 0.06

    *

    comment cleanup

    *

    add flexible debug messages

    new in 0.07

    *

    useless "no strict" outcommented

    *

    fixed a bug that happened when splitting messages containing newlines

    *

    added documentation

    new in 0.08

    *

    added contact information

    *

    bugfix for error handling $@

    *

    module renamed to Net::NetSend

    *

    argument count check

    *

    4022 bytes -> 4021 chars

    new in 0.10

    *

    POD documentation

    new in 0.11

    *

    Cut message size to 4000 chars. This is more safe. Before, sending could fail if message length plus source netbios name plus target nebios name were greater than 4032 chars.

    *

    An accidentally German error message was translated to English and extended to give more information about the error. Thanks to Tom Metro for reporting this and some other things.

    *

    Documentation about caveats added.

    *

    Bugfix for accumulating error texts as reported by brae.charles at mail.com. (Thanks!)

    *

    POD documentation extended.

    *

    Error messages improved to give more information about the error.

AUTHOR

Florian Greb, <greb@cpan.org>

COPYRIGHT

Copyright (c) 2004 Florian Greb. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

7 POD Errors

The following errors were encountered while parsing the POD:

Around line 608:

You can't have =items (as at line 612) unless the first thing after the =over is an =item

Around line 635:

You can't have =items (as at line 639) unless the first thing after the =over is an =item

Around line 654:

You can't have =items (as at line 658) unless the first thing after the =over is an =item

Around line 669:

You can't have =items (as at line 673) unless the first thing after the =over is an =item

Around line 688:

You can't have =items (as at line 692) unless the first thing after the =over is an =item

Around line 715:

You can't have =items (as at line 719) unless the first thing after the =over is an =item

Around line 726:

You can't have =items (as at line 730) unless the first thing after the =over is an =item