Public feed
#533540
<?php require_once 'bencode.php'; class Intermission { var $daemon_version; var $sock; var $version = array('version' => array('min' => 1, 'max' => 2)); function Intermission($daemon_socket) { $this->sock = socket_create(AF_UNIX, SOCK_STREAM, 0); socket_connect($this->sock, $daemon_socket); $this->daemon_version = $this->sock_write($this->version); } function sock_close() { socket_close($this->sock); } function sock_read() { return bdecode(socket_read($this->sock, hexdec(socket_read($this->sock, 8)))); } function sock_write($data) { $data = bencode($data); socket_write($this->sock, sprintf('%08X', strlen($data)) . $data); return $this->sock_read(); } }?>