Perl IO::Handle/Socket behavior 5.2 vs 4.9

From: Chris Ochs <freebsd-current_at_paymentonline.net>
Date: Tue, 23 Dec 2003 14:20:04 -0800
This code is in the Memcached.pm module that connects to the memcached
deamon (memcached is in ports).

On 5.2 the connect returns null unless I comment out the lines calling
IO::Handle::blocking.  On 4.9 it works fine.  Any ideas why?

Chris


sub _connect_sock { # sock, sin, timeout
    my ($sock, $sin, $timeout) = _at__;
    $timeout ||= 0.25;

    my $block = IO::Handle::blocking($sock, 0) if $timeout;

    my $ret = connect($sock, $sin);

    if (!$ret && $timeout && $!{'EINPROGRESS'}) {

        my $win='';
        vec($win, fileno($sock), 1) = 1;

        if (select(undef, $win, undef, $timeout) > 0) {
            $ret = connect($sock, $sin);
            # EISCONN means connected & won't re-connect, so success
            $ret = 1 if !$ret && $!{'EISCONN'};
        }
    }

    IO::Handle::blocking($sock, $block) if $timeout;
    return $ret;
}
Received on Tue Dec 23 2003 - 13:18:09 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:35 UTC