S
sgt_b2002
Working on a small utility and everything works perfectly using
IO:Socket::INET. When I move over to using IO::Socket::SSL, a certain
piece of code no longer works. Essentially, this is a "one client only"
application. If the original socket is defined, subsequent connections
are immediately closed. When using IO::Socket::INET, this works great.
Moving over to SSL, things die.
Here when a non SSL connection is established, the new $sock object is
never defined. Because it is not defined, calls to it obviously fail.
Shouldn't $tempsock be created regardless of whether or not SSL is
being used? I'm thinking that SSL_error_trap was designed to deal with
those cases.
Right now, the below code will kill the server if a non SSL client
connects. Here is the error:
Bad arg length for Socket::unpack_sockaddr_in, length is 0, should be
16 at /usr/lib/perl5/5.8.7/i686-linux/Socket.pm line 370.
If I remove everything but the $tempsock object, I'll get a "can't call
method close on an undefined object".
Any ideas?
[code snippet]
$agent_sock = new IO::Socket::SSL(
LocalHost => $aip,
LocalPort => $aport,
Proto => 'tcp',
Listen => 1,
Reuse => 1,
SSL_cert_file => 'server.crt',
SSL_key_file => 'server.key',
SSL_error_trap => \&ssl_error,
);
$agent_sock or die "Socket error: $!";
$sel = IO::Select->new($agent_sock);
while(@ready = $sel->can_read) {
foreach $fh (@ready) {
if ($fh == $agent_sock) {
if (defined $asock) {
my $tempsock = $agent_sock->accept();
my ($tempsock,$tempaddr) = $agent_sock->accept();
my ($tempport, $tempip) = sockaddr_in($tempaddr);
my $tempipnum = inet_ntoa($tempip);
$tempsock->close;
print "Closed an unsolicited Agent connection from
".$tempipnum.':'.$tempport."\n";
last;
}
($asock, $a_addr) = $agent_sock->accept();
($a_port, $a_ip) = sockaddr_in($a_addr);
$a_ipnum = inet_ntoa($a_ip);
print "Relay Agent connecting from: $a_ipnum:$a_port\n";
$sel->add($asock);
<snip>
[/code snippet]
IO:Socket::INET. When I move over to using IO::Socket::SSL, a certain
piece of code no longer works. Essentially, this is a "one client only"
application. If the original socket is defined, subsequent connections
are immediately closed. When using IO::Socket::INET, this works great.
Moving over to SSL, things die.
Here when a non SSL connection is established, the new $sock object is
never defined. Because it is not defined, calls to it obviously fail.
Shouldn't $tempsock be created regardless of whether or not SSL is
being used? I'm thinking that SSL_error_trap was designed to deal with
those cases.
Right now, the below code will kill the server if a non SSL client
connects. Here is the error:
Bad arg length for Socket::unpack_sockaddr_in, length is 0, should be
16 at /usr/lib/perl5/5.8.7/i686-linux/Socket.pm line 370.
If I remove everything but the $tempsock object, I'll get a "can't call
method close on an undefined object".
Any ideas?
[code snippet]
$agent_sock = new IO::Socket::SSL(
LocalHost => $aip,
LocalPort => $aport,
Proto => 'tcp',
Listen => 1,
Reuse => 1,
SSL_cert_file => 'server.crt',
SSL_key_file => 'server.key',
SSL_error_trap => \&ssl_error,
);
$agent_sock or die "Socket error: $!";
$sel = IO::Select->new($agent_sock);
while(@ready = $sel->can_read) {
foreach $fh (@ready) {
if ($fh == $agent_sock) {
if (defined $asock) {
my $tempsock = $agent_sock->accept();
my ($tempsock,$tempaddr) = $agent_sock->accept();
my ($tempport, $tempip) = sockaddr_in($tempaddr);
my $tempipnum = inet_ntoa($tempip);
$tempsock->close;
print "Closed an unsolicited Agent connection from
".$tempipnum.':'.$tempport."\n";
last;
}
($asock, $a_addr) = $agent_sock->accept();
($a_port, $a_ip) = sockaddr_in($a_addr);
$a_ipnum = inet_ntoa($a_ip);
print "Relay Agent connecting from: $a_ipnum:$a_port\n";
$sel->add($asock);
<snip>
[/code snippet]