version 1.23, 2003/11/04 11:23:37
|
version 1.24, 2003/11/04 11:36:04
|
Line 80 my $ServerPort; # Port used to connect
|
Line 80 my $ServerPort; # Port used to connect
|
my $TransitionTimeout = 5; # Poll timeout in seconds. |
my $TransitionTimeout = 5; # Poll timeout in seconds. |
|
|
|
|
LondConnection::SetDebug(10); |
# LondConnection::SetDebug(10); |
|
|
|
|
# |
# |
Line 195 sub NegotiateStartup {
|
Line 195 sub NegotiateStartup {
|
|
|
return $returnstatus; |
return $returnstatus; |
} |
} |
|
# |
|
# Perform a transaction with the remote lond. |
|
# Paramters: |
|
# connection - the connection object that represents |
|
# a LondConnection to the remote lond. |
|
# command - The request to send to the remote system. |
|
# Returns: |
|
# The 'reaction' of the lond to this command. |
|
# However if the connection to lond is lost during the transaction |
|
# or some other error occurs, the text "error:con_lost" is returned. |
|
# |
sub PerformTransaction { |
sub PerformTransaction { |
my $connection = shift; |
my $connection = shift; |
my $command = shift; |
my $command = shift; |
|
my $retval; # What we'll returnl. |
|
|
|
# Set up the connection to do the transaction then |
|
# do the I/O until idle or error. |
|
# |
|
$connection->InitiateTransaction($command); |
|
my $error = 0; |
|
my $Socket = $connection->GetSocket; |
|
my $state; |
|
|
|
while (($connection->GetState ne "Idle") && (!$error)) { |
|
# |
|
# Wait for the socket to get into the appropriate state: |
|
# |
|
my $wantread = $connection->WantReadable; |
|
my $poll = new IO::Poll; |
|
$poll->mask($Socket => $wantread ? POLLIN : POLLOUT); |
|
$poll->poll($TransitionTimeout); |
|
my $done = $poll->handles(); |
|
if(scalar($done) == 0) { # Timeout!!! |
|
print "Error: Timeout in state : $state negotiating connection\n"; |
|
$retval = "error"; |
|
$error = 1; |
|
} else { |
|
my $status; |
|
$status = $wantread ? $connection->Readable : $connection->Writable; |
|
if ($status != 0) { |
|
print "Error: I/O failed in state : $state negotiating connection\n"; |
|
$retval = "error"; |
|
$error = 1; |
|
} |
|
} |
|
} |
|
# |
|
# Fetch the reply from the transaction |
|
# |
|
if(! $error) { |
|
$retval = $connection->GetReply; |
|
} |
|
|
return "ok"; |
return $retval; |
} |
} |
# |
# |
# Performs a transaction direct to a remote lond. |
# Performs a transaction direct to a remote lond. |