User since
2005-05-31
8
Artikel
BenutzerIn
Hi Folks
I have a Perl-Script that tries to connect each minute via SFTP.
But i receive this error every second try, because the socket is still occupied by my connection:
Net::SSH: Can't bind socket to port 1023: Die Adresse wird bereits verwendet at /usr/lib/perl5/site_perl/5.8.5/Net/SFTP.pm line 61
I tried to figure out if there is a methode for a clean shutdown of my SFTP-Object (like $sftp->quit())...or something like this.
But i did find anything yet.
Somebody an idea how to solve this problem?
Thanks and gratz
prassito
User since
2003-08-04
14371
Artikel
ModeratorIn
I would use the
$sftp-object in a very small scope. If you leave the scope, the object would be destroyed and the connection should be refused.
User since
2005-05-31
8
Artikel
BenutzerIn
Thanks for the answers
But i am sorry to say, that both advices did not lead to a solution.
Neither undefining nor strictly limiting the existence of the object frees the port. I still get:
Net::SSH: Can't bind socket to port 1023...
Any other hints or solutions?
Thanks anyway.
Gratz
prassito\n\n
<!--EDIT|prassito|1117533540-->
User since
2003-08-14
803
Artikel
BenutzerIn
are your shure that this port (1023) is not opend by other programs?
normaly sftp used port 22.
regards rambo
User since
2003-08-04
7321
Artikel
ModeratorIn
and, why don't u reuse your object anyway?
User since
2005-05-31
8
Artikel
BenutzerIn
Hi Folks
Yes i am sure, that i use this port.
It is defined in:
Net/SSH/Perl.pm
But while looking for this, i found the solution for my task (i know not the best one).
In Line 223 and 224 in the sub _create_socket() you i found this:
my ($p,$end,$delta) = (0,1,1); # normally we use whatever port we can get
($p,$end,$delta) = (1023,512,-1) if $ssh->{config}->get('privileged') ;
I removed the line 224 and now my Script uses different ports to connect.
Anyway thanks for the help.
Gratz
prassito\n\n
<!--EDIT|prassito|1117535705-->