Hi All
I have successfully install the openssl on my Redhet linux7 System.
I also able to run "SSL Server" and "SSL Client" on same.
All is going fine but i am having problem on ssl_server.pl file.
Code:
#SSL Server Data receive loop
while (1) {
warn "waiting for next connection.\n";
while(($s = $sock->accept())) {
my ($peer_cert, $subject_name, $issuer_name, $date, $str);
if( ! $s ) {
warn "error: ", $sock->errstr, "\n";
next;
}
warn "connection opened ($s).\n";
if( ref($sock) eq "IO::Socket::SSL") {
$subject_name = $s->peer_certificate("subject");
$issuer_name = $s->peer_certificate("issuer");
}
warn "\t subject: '$subject_name'.\n";
warn "\t issuer: '$issuer_name'.\n";
#My change code *******************************
$temp_off=1;
$temp_off=1;
while ($s->peek($temp_r,75,$temp_off))
{
warn "\n waiting for data. \n";
print "\n Incomming Message: ";
print $temp_r; #This line print incoming data
#$temp_r="";
#print "\n Length: $temp_size \t Offset: $temp_off";
$temp_off=$temp_off+length($temp_r);
}
#End my change code ***************************
my $date = localtime();
print $s "my date command says it's: '$date'";
close($s);
warn "\t connection closed.\n";
}
}
#End SSL Server Data Receive Loop
Problem:
I have a problem that when my ssl_server's socket receive the data
from client the data displays but
in that while loop just it while loop it just goingon and cant break
from that loop.
I know there is only some logical error in my code. I aslo set the
increment of OffSet by the size of
data but no any result come.
See above code the Print $temp_r function print the received data.
after once data received the cursor doesn't break the loop.
I don't know weather i have to use the thread or some else.
Any idea or small code/tips how to write server.
Thanks in advance.
Regards
Rushi
|