+sub fetch_tcp_multi(@) {
+ my $address = shift;
+ my $port = shift;
+ my $delimiter = shift;
+ my %values;
+
+ my $sock = IO::Socket::INET->new(PeerAddr => $address,
+ PeerPort => $port,
+ Proto => 'tcp',
+ Timeout => 1);
+
+ return undef if (!$sock);
+
+ my $select = IO::Select->new($sock);
+
+ while($select->can_read(1)) {
+ if (sysread($sock, my $buf, 16384) > 0) {
+ $buf=~s/\r//g;
+ foreach my $line (split(/\n/, $buf)) {
+ (my $key, my $value) = split(/${delimiter}/, $line);
+ $value=~ s/\s//g;
+ $values{$key} = $value;
+ }
+ } else {
+ last;
+ }
+ }
+
+ close($sock);
+
+ %values;
+}
+