IO::Socket and LWP::UserAgent

tim tim.hunt at
Thu Nov 21 00:16:58 CST 2002


I'm trying to connect to a service provider using two methods:

HTTPS:// GET via LWP::UserAgent;
TCP/IP stream via IO::Socket::SSL;

In each case I'm sending information to be SMSed to mobile phones.

My script instantiates an object and then calls the specific ->send()
method; in each case the object is reused. The HTTPS method is about
three times faster than the socket method. The socket seems to put one
message per second, whilst the supplier has suggested that 20 per second
is achievable.

Am I missing something intrinsic about IO::Socket::SSL (and IO::Socket
in general), or shoudl I be talking to the provider to get their system
tuned? They use Win NT as their server, and that's about all I know :)

Thanks in advance,



my $sms = new Monash::SMS_Stunnel($account, $pass);
my $ssl_mobile_number = '0419xxxxxxxxx';
my $message = 'TEXT for test purposes';
my $str;
map {
    $response = $sms->send_socket_SSL($ssl_mobile_number, $message);
    if ($response) {
        $str = "Message $_ sent from process $$";
    } else {
        $str = "Message $_ failed from process $$";
    carp $str;
} (1..200);


sub new
   use IO::Socket::SSL;
   my $remote_ssl = IO::Socket::SSL->new(
               Proto=> 'tcp',
               PeerAddr => 'xx.xx.xx.xx',
               PeerPort => 'xxx',
             or die "cannot connect to [SSL] server";

    my ($clazz, $account_name, $passwd) = @_;

    my $self = {
        _account_name   => $account_name,
        _passwd     => $passwd,
        _remote_ssl => $remote_ssl,

    bless $self, $clazz;
    return $self;

sub send_socket_SSL($)
    my ($self,$mobile_number,$message) = @_;

    # These three should form part of the object invocation:
    my $sender = 'xxxxxx';
    my $sender_address = 'xxxxxxxxxxxxxx';
    my $recipient = 'xxxxxxxxxxxxx';
    my $remote = $self->{_remote_ssl};
    # Okay, let's send it!
    print $remote qq{\r\r}.$self->{_account_name}.qq{\r1\r1\r}.

    # Send result
    # Accepted Result code = 0x06 Description = Lodge OK
    # Rejected Result code = 0x15 Description = Lodge Error

    my $strbuff = '';
    # Next line for debug purposes only:
#   print "\nstrbuff was ($strbuff)\n";
    if ($strbuff =~ /Lodge OK/) {
        return 1;
    } else {
        return 0;


More information about the Melbourne-pm mailing list