forked from tpruvot/ccminer
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: sample command line api call in perl
tx to lilyth for the idea (works on cpuminer, sgminer and cgminer too)
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/perl | ||
|
||
# sample script to query ccminer API | ||
|
||
my $command = "summary|"; | ||
|
||
use Socket; | ||
use IO::Socket::INET; | ||
|
||
my $sock = new IO::Socket::INET ( | ||
PeerAddr => '127.0.0.1', | ||
PeerPort => 4068, | ||
Proto => 'tcp', | ||
ReuseAddr => 1, | ||
Timeout => 10, | ||
); | ||
|
||
if ($sock) { | ||
|
||
print $sock $command; | ||
my $res = ""; | ||
|
||
while(<$sock>) { | ||
$res .= $_; | ||
} | ||
|
||
close($sock); | ||
print("$res\n"); | ||
|
||
} else { | ||
|
||
print("ccminer socket failed\n"); | ||
|
||
} |