public function test_jaxl_socket_client() { $sock = new JAXLSocketClient(); $sock->connect('tcp://127.0.0.1:5222'); $sock->send("<stream:stream>"); while ($sock->fd) { $sock->recv(); } }
function test_jaxl_socket_client() { $sock = new JAXLSocketClient("127.0.0.1", 5222); $sock->connect(); $sock->send("<stream:stream>"); while ($sock->fd) { $sock->recv(); } }
/** * @param string $name * @param callable $read_cb TODO: Currently not used */ public function __construct($name, $read_cb = null) { // TODO: see JAXL->cfg['priv_dir'] $this->pipes_folder = getcwd() . '/.jaxl/pipes'; if (!is_dir($this->pipes_folder)) { mkdir($this->pipes_folder, 0777, true); } $this->ev = new JAXLEvent(); $this->name = $name; // TODO: If someone's need the read callback and extends the JAXLPipe // to obtain it, one can't because this property is private. $this->read_cb = $read_cb; $pipe_path = $this->get_pipe_file_path(); if (!file_exists($pipe_path)) { posix_mkfifo($pipe_path, $this->perm); $this->fd = fopen($pipe_path, 'r+'); if (!$this->fd) { JAXLLogger::error("unable to open pipe"); } else { JAXLLogger::debug("pipe opened using path {$pipe_path}"); JAXLLogger::notice("Usage: \$ echo 'Hello World!' > {$pipe_path}"); $this->client = new JAXLSocketClient(); $this->client->connect($this->fd); $this->client->set_callback(array(&$this, 'on_data')); } } else { JAXLLogger::error("pipe with name {$name} already exists"); } }
public function negotiate() { $pkt = pack("C3", 0x5, 0x1, 0x0); $this->client->send($pkt); // enter sub-negotiation state }