469,927 Members | 1,860 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

Time out SSL request?

Hi folks,

I'm using perl (actually, mod_perl environment on RH 8.0) to connect
to an external SSL server. I feed it an XML request and get a
response back. The problem is, the server is flaky, and I'd like to
be able to timeout / break if I haven't gotten a response in X
seconds. (Note that the server may connect, but simply not send a
response, i.e., it's too busy.)

I don't really understand filehandles and setting timeouts in unix /
perl. The code below was lifted from the Net::SSLeay readme and
worked, and I never questioned it further.

Could someone show me how to modify the code below to add my timeout?
Note that I'm also completely open to other methods of connecting to
an SSL server; the Net::SSLeay method seemed to be the quickest to
implement, and I have no idea if there's a better way out there.

Thanks!

Michael

#!/usr/local/bin/perl -w

use strict;
use Net::SSLeay::Handle qw/shutdown/;

my ($request, $response) ;

local *F;
my $FH = *F;

$request = <<ENDXML;
<?xml version="1.0"?>
<Request>
<UserId>user1</UserId>
<Password>pass1</Password>
</Request>
ENDXML

my ($host, $port) = ("www.some.server", 443);
tie(*SSL, "Net::SSLeay::Handle", $host, $port);

print SSL "POST /xmlapps/blah HTTP/1.0\n";
print SSL "Content-type: application/x-www-form-urlencoded\n";
print SSL "Content-length: " . length($request) . "\n\n";
print SSL $request;

shutdown(\*SSL, 1);

$response .= $_ while (<SSL>);
close SSL;
print $response;
Jul 19 '05 #1
0 1602

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Hans | last post: by
reply views Thread by daniel.rolfe | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.