# Data to send, when other end is ready for it my($BUFF)=''; # Buffer in case calling script misses a few events sub Leap { my $ret; if($BUFF eq '') { # Nothing in the buffer - try to get some more unless($LEAP_HANDLE) { # Establish a new connection # Make the socket socket($LEAP_HANDLE, PF_INET, SOCK_STREAM, getprotobyname('tcp')) || return (\{'error' => "socket: $!"}); # Don't let stuff like UTF-style characters get screwed up binmode($LEAP_HANDLE) || return (\{'error' =>,"binmode(socket handle): $!"}); # Allow more than one connection setsockopt($LEAP_HANDLE, SOL_SOCKET, SO_REUSEADDR, 1) || return (\{'error' =>,"SO_REUSEADDR: $!"}); # Don't block on close (Remember not to close it until we've sent everything we want):- if($^O =~/Win32/i) { setsockopt($LEAP_HANDLE, SOL_SOCKET, SO_DONTLINGER, 1) || return (\{'error' =>,"SO_DONTLINGER: $!"}); } vec($bitsr,fileno($LEAP_HANDLE),1)=1; # This tells select() which socket we want to query vec($null,fileno($LEAP_HANDLE),1)=0; if(defined $SEND) {$bitsw=$bitsr} else {$bitsw=$null} # We only care about write-status if we've got data to write