binmode(STDOUT, ":utf8");
binmode(STDIN, ":utf8");
-use IO::Socket::INET6;
use Getopt::Long qw(:config gnu_getopt);
use lib "$FindBin::Bin";
use MPDHacks;
-my $host = $ENV{MPD_HOST} // "localhost";
-my $port = $ENV{MPD_PORT} // 6600;
my ($quiet, $binary, $ignore_errors, $download);
sub print_version {
}
GetOptions(
- 'host|h=s' => \$host,
- 'port|p=s' => \$port,
+ 'host|h=s' => \$MPD::host,
+ 'port|p=s' => \$MPD::port,
'quiet|q' => \$quiet,
'no-quiet' => sub { $quiet = 0; },
}
$quiet = 1 if (defined($binary) && $binary eq "");
-my $sock = new IO::Socket::INET6(
- PeerAddr => $host,
- PeerPort => $port,
- Proto => 'tcp',
-) or die "failed to connect to MPD: $!";
-#binmode($sock, ":utf8");
-binmode($sock);
-
-if (!(<$sock> =~ /^OK MPD ([0-9]+)\.([0-9]+)\.([0-9]+)$/)) {
- die "MPD failed to announce version: $!";
-}
+my $sock = MPD::connect(binmode => ":raw");
sub read_binary {
my ($count) = @_;