/home/lnzliplg/www/alt-php81-pecl-zmq_1.1.3-1.84f0720.el8.zip
PK&��\R����tests/bug_gh_43.phptnu�[���--TEST--
Test for Github issue #43
--SKIPIF--
<?php 
    require_once(dirname(__FILE__) . '/skipif.inc'); 
?>
--FILE--
<?php

error_reporting(0);

$context = new ZMQContext (1, false);

$sock1 = new ZMQSocket ($context, ZMQ::SOCKET_PUB);
$sock2 = new ZMQSocket ($context, ZMQ::SOCKET_SUB);

try {
    $device = new ZMQDevice ($sock1, $sock1, $sock1, $sock1);
    // on PHP7 and lower
    $lastError = error_get_last();
    if(strpos($lastError['message'], 'ZMQDevice::__construct() expects at most 3 parameters, 4 given') !== false)
     	echo "OK\n";
    else{
        echo "FAIL\n";
        print_r($lastError);
    }
}catch(TypeError $e){
 	echo "OK\n"; // on PHP8
}
--EXPECT--
OK
PK&��\|��tests/skipif-libzmq3.incnu�[���<?php
if (!defined('ZMQ::LIBZMQ_VERSION_MAJOR') || ZMQ::LIBZMQ_VERSION_MAJOR != 3) {
    die ("skip This test is for PHP7 and libzmq version 3.x");
}
?>

PK&��\��ĭtests/003-getpersistentid.phptnu�[���--TEST--
Test getting persistent id
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$client = create_server('hello');
var_dump($client->getPersistentId());

--EXPECT--
string(5) "hello"PK&��\�*͔99tests/007-addremovepoll.phptnu�[���--TEST--
Test adding / removing items
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

/* Create socket, request-reply pattern (reply socket) */
$s = create_server();
$z = create_client();


/* Create PHP stream socket */
$socket_server = stream_socket_server("tcp://127.0.0.1:5858", $errno, $errstr);

if (!$socket_server) {
	echo "Failed to create socket server: {$errstr}" . PHP_EOL;
	exit (1);
}

$socket_client = stream_socket_client("tcp://127.0.0.1:5858", $errno, $errstr);

if (!$socket_client) {
	echo "Failed to create socket client: {$errstr}" . PHP_EOL;
	exit (1);
}

/* Accept the client connection */
$stream = stream_socket_accept ($socket_server);

/* Write something from client so that connection will be readable and writable */
fwrite($socket_client, "1");

$poll   = new ZMQPoll();
$obj_id = $poll->add($z, ZMQ::POLL_IN);
$fp_id  = $poll->add($stream, ZMQ::POLL_IN | ZMQ::POLL_OUT);

var_dump($obj_id, $fp_id, $poll->count());

$readable = array();
$writable = array();
$poll->poll($readable, $writable, 1000);
var_dump($readable, $writable);

fclose ($stream);
fclose ($socket_client);
fclose ($socket_server);

var_dump($poll->poll($readable, $writable, 1000));
var_dump($poll->getLastErrors());

$poll->remove($fp_id);

$poll->clear();
var_dump($poll->count());

--EXPECTF--
string(34) "o:%s"
string(3) "r:%d"
int(2)
array(1) {
  [0]=>
  resource(%d) of type (stream)
}
array(1) {
  [0]=>
  resource(%d) of type (stream)
}
int(1)
array(1) {
  [0]=>
  string(3) "r:%d"
}
int(0)
PK&��\�x#���tests/009-ispersistent.phptnu�[���--TEST--
Test ispersistent on context and socket
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

/* Persistent context */
$context = new ZMQContext();
$socket  = $context->getSocket(ZMQ::SOCKET_REQ, 'persistentId');
$socket2 = $context->getSocket(ZMQ::SOCKET_REQ, null);

var_dump($context->isPersistent(), 
         $socket->isPersistent(),
         $socket->getPersistentId(),
         $socket2->isPersistent(),
         $socket2->getPersistentId());

/* Non-persistent context */
$context = new ZMQContext(1, false);
$socket  = $context->getSocket(ZMQ::SOCKET_REQ, 'persistentId');
$socket2 = $context->getSocket(ZMQ::SOCKET_REQ, null);

var_dump($context->isPersistent(), 
         $socket->isPersistent(),
         $socket->getPersistentId(),
         $socket2->isPersistent(),
         $socket2->getPersistentId());


--EXPECTF--
bool(true)
bool(true)
string(12) "persistentId"
bool(false)
NULL
bool(false)
bool(false)
NULL
bool(false)
NULLPK&��\����tests/025-sendrecvmulti.phptnu�[���--TEST--
Test send / recv for multipart messages
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$server = create_server();
$client = create_client();

$message = array("Hello", "World", 12314);

$client->sendmulti($message);

var_dump($message);

$messages = $server->recvmulti();
var_dump($messages);

$e = $server->sendMulti($message);
var_dump($e == $server);

--EXPECT--
array(3) {
  [0]=>
  string(5) "Hello"
  [1]=>
  string(5) "World"
  [2]=>
  int(12314)
}
array(3) {
  [0]=>
  string(5) "Hello"
  [1]=>
  string(5) "World"
  [2]=>
  string(5) "12314"
}
bool(true)PK&��\��P���tests/015-callback.phptnu�[���--TEST--
Test basic callback usage
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'my persistent 1', 'bind_callback');
var_dump($socket->getEndpoints());

$ctx = new ZMQContext();
$socket = $ctx->getSocket(ZMQ::SOCKET_REQ, 'my persistent 2', 'bind_callback');
var_dump($socket->getEndpoints());


--EXPECT--
array(2) {
  ["connect"]=>
  array(0) {
  }
  ["bind"]=>
  array(1) {
    [0]=>
    string(22) "inproc://php-test-5566"
  }
}
array(2) {
  ["connect"]=>
  array(0) {
  }
  ["bind"]=>
  array(1) {
    [0]=>
    string(22) "inproc://php-test-5567"
  }
}PK&��\$��

tests/026-sockettype.phptnu�[���--TEST--
Test returning socket type
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

$context = new ZMQContext();

var_dump ($context->getSocket(ZMQ::SOCKET_PUSH)->getSocketType() === ZMQ::SOCKET_PUSH);

var_dump ($context->getSocket(ZMQ::SOCKET_PUB)->getSocketType() === ZMQ::SOCKET_PUB);

$socket = $context->getSocket(ZMQ::SOCKET_ROUTER);

var_dump ($socket->getSocketType() === $socket->getSockOpt(ZMQ::SOCKOPT_TYPE));

echo "OK\n";

--EXPECTF--
bool(true)
bool(true)
bool(true)
OK
PK&��\jl�%%tests/035-capture.phptnu�[���--TEST--
Test device capture
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
require dirname(__FILE__) . '/zeromq_test_helper.inc';

$context = new ZMQContext();

$front = new ZMQSocket($context, ZMQ::SOCKET_PULL);
$front->bind (ZEROMQ_TEST_DSN);

$sender = new ZMQSocket($context, ZMQ::SOCKET_PUSH);
$sender->connect(ZEROMQ_TEST_DSN);

$backend = new ZMQSocket($context, ZMQ::SOCKET_PUSH);
$backend->bind (ZEROMQ_TEST_DSN2);

$receiver = new ZMQSocket($context, ZMQ::SOCKET_PULL);
$receiver->connect(ZEROMQ_TEST_DSN2);

$capture = new ZMQSocket($context, ZMQ::SOCKET_PUB);
$capture->bind ('inproc://capture');

$capture_listener = new ZMQSocket($context, ZMQ::SOCKET_SUB);
$capture_listener->connect ('inproc://capture');
$capture_listener->setSockOpt (ZMQ::SOCKOPT_SUBSCRIBE, "");

$device = new ZMQDevice($front, $backend, $capture);
$device->setIdleCallback(function () { return false; }, 100, 'ddd');

$sender->sendmsg ("Hello backend");
$device->run ();
$device->run ();

echo "Receiving from receiver" . PHP_EOL;
var_dump($receiver->recvmsg());

echo "Receiving from capture listener" . PHP_EOL;
var_dump($capture_listener->recvmsg());

echo "OK";
?>
--EXPECT--
Receiving from receiver
string(13) "Hello backend"
Receiving from capture listener
string(13) "Hello backend"
OKPK&��\�u5,,tests/rose.jpgnu�[������JFIFHH��C	!"$"$��C��.F"����3!1QAa"���#2Rq��B�����*!1AQaq���2���?rT��@��^̇勺8�c鵶8$�p�L�MR�&d%�XVF��7$��F%"LʂD�{D�
50&�3��@�i��骒2l؜J�I涖
�
��n^YnYϠ�-���Q$��'*���'���MD\k�
XX�D�F�m�a��0H�PGC�bF����5�A�s��ܣ�$�q�d�R
�]��$�e����.�Eͅ�~�p-'KZ�p���֘=/m�^�.#č3W�f���Q<��[����djs�$t�@��
����	y3-llFp��y���q��ޔҕzֳ/��Ee'�%�#����T�%��߇�LŽ4�}9�Y�X��߬5>KG�e0�sU�Dj	Eh�UA;�p��ӄ�PKOP��*t����[��Ō�M����x�t��T';1�\��VO����\UIOO��I��<�������`JHee[�lk�|T�T�F[[(FR���G�=�B�Z%;�l�s�iY�r���E%x�Q�f��v2m��1B�1��wUs������esE�(p�+��c��}~X���������L�������K�Ou�`���gLʴ�N~�n�e`���[��9FIF話�Cq�c����o 
��a���3�ma�q�vE¸���r��'��?�~�8pۋ��C��9��iu6a6[^�R‚2�,�%nA��q��+��*)���C��7A�8��[,��)j+[0�U�$����
<b��fb{t��d��(��s�Z�4���S�X��?����y�P+�)��ouL���f�@������v���ZQm�s$�dP����k4G
�N"P��EWKG'�$��-!a�댺�q�\�h8;O1@�F�`}�|�QTX��	3�nq��&�Օڲmt�G-Bd�eB���X�~���Q>_QUG5#Q֠+*H�]
���c�t�_CRg1RƕـQ5���	�1]�-�u�:G�ӴU`��,��O�/���f��xk�}S6@�Fe�x���g�U��F
~�f�1�q��3��|x����E�̡�2r^��h�m�� ����
ө[�i�;t���Q�S7
�V6=���9����"�I�RZ+
���L���l�F��0�QE�������F��ED�v��m�<��Xb��C-��$}1�d�Ks����=�7h/fy�/w(��.v��ㅁ�d�~��H,���&�����(���$G��PK&��\���&tests/017-callbackonlyonnewsocket.phptnu�[���--TEST--
Test that callback is only called on new socket
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'persistent_socket', 'bind_callback');
$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'persistent_socket', 'bind_callback');
$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'persistent_socket', 'bind_callback');
$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'persistent_socket', 'bind_callback');
$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'persistent_socket', 'bind_callback');

$array = $socket->getEndpoints();

echo count($array['bind']) . "\n";
echo "OK";

--EXPECT--
1
OKPK&��\!M��tests/041-cert-meta.phptnu�[���--TEST--
Test a ZMQCert can get and set metadata.
--SKIPIF--
<?php

	require_once __DIR__ . '/skipif.inc';
	require_once __DIR__ . '/skipif-czmq2.inc';
--FILE--
<?php

$cert = new ZMQCert();
var_dump($cert->getMeta('foo'));
var_dump($cert->getMetaKeys());

$cert->setMeta('foo', 'bar');
var_dump($cert->getMeta('foo'));
var_dump($cert->getMetaKeys());

$cert->setMeta('baz', 'qux');
var_dump($cert->getMetaKeys());

// This should generate an error
var_dump($cert->getMetaKeys(123));
--EXPECTF--
NULL
array(0) {
}
string(3) "bar"
array(1) {
  [0]=>
  string(3) "foo"
}
array(2) {
  [0]=>
  string(3) "baz"
  [1]=>
  string(3) "foo"
}

Warning: ZMQCert::getMetaKeys() expects exactly 0 parameters, 1 given in %s on line %d
NULL
PK&��\1L�5��tests/043-cert-load.phptnu�[���--TEST--
Test a ZMQCert can be loaded.
--SKIPIF--
<?php

	require_once __DIR__ . '/skipif.inc';
	require_once __DIR__ . '/skipif-czmq2.inc';
--FILE--
<?php

define('BASE_CERT_DIR', __DIR__ . '/certs');
mkdir(BASE_CERT_DIR);

$certPath = BASE_CERT_DIR . '/cert';
$cert = new ZMQCert();
$cert->save($certPath);

$certCloneEquivalent = new ZMQCert($certPath);
var_dump($certCloneEquivalent->equals($cert));

unlink($certPath);
unlink($certPath . '_secret');

try {
	new ZMQCert('/path/to/cert');
} catch (ZMQCertException $e) {
	var_dump($e->getMessage());
}

rmdir(BASE_CERT_DIR);
--EXPECT--
bool(true)
string(49) "Failed to load the certificate from /path/to/cert"
PK&��\9��T��tests/055-socks-proxy.phptnu�[���--TEST--
Test socks proxy
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
if(!@fsockopen('127.0.0.1', 5557, $errCode, $errStr, 0.1))
    die ('skip test requires local SOCKS5 proxy on port 5557');
?>
--FILE--
<?php

// local socks proxy can be enabled by running sshd and also running
// ssh -D 5557 -C -N root@localhost

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$context = new ZMQContext();
$server  = $context->getSocket(ZMQ::SOCKET_REP, null)
               ->bind('tcp://127.0.0.1:5556');
$context = new ZMQContext();
$client  = $context->getSocket(ZMQ::SOCKET_REQ, null);
$client->setSockOpt(ZMQ::SOCKOPT_SOCKS_PROXY, "localhost:5557");
$client ->connect('tcp://127.0.0.1:5556');

$client->sendmsg("Hello world!");

$message = $server->recvmsg();
var_dump($message);
$server->sendmsg($message);

$message = $client->recvmsg();
var_dump($message);

--EXPECT--
string(12) "Hello world!"
string(12) "Hello world!"PK&��\TޤR9R9tests/libzmq2-sockopt.phptnu�[���--TEST--
Test setting socket options
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
if (!defined('ZMQ::LIBZMQ_VERSION_MAJOR') || ZMQ::LIBZMQ_VERSION_MAJOR < 2) {
    die ("skip This test is for PHP7 and libzmq version 2.x and up");
}
?>
--FILE--
<?php

$tested = 0;

$removedVersion = 3;
/* socket option is marked mode="rw" type=uint64 php_type=int */
if (defined ("ZMQ::SOCKOPT_HWM") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_HWM, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_HWM);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_HWM) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_HWM: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = 3;
/* socket option is marked mode="rw" type=int64 php_type=int */
if (defined ("ZMQ::SOCKOPT_SWAP") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_SWAP, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_SWAP);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_SWAP) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_SWAP: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=uint64 php_type=int */
if (defined ("ZMQ::SOCKOPT_AFFINITY") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_AFFINITY, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_AFFINITY);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_AFFINITY) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_AFFINITY: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=string php_type=string */
if (defined ("ZMQ::SOCKOPT_IDENTITY") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = "test";

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_DEALER);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_IDENTITY, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_IDENTITY);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_IDENTITY) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_IDENTITY: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=int64 php_type=int */
if (defined ("ZMQ::SOCKOPT_RATE") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_RATE, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_RATE);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_RATE) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_RATE: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=int64 php_type=int */
if (defined ("ZMQ::SOCKOPT_RECOVERY_IVL") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_RECOVERY_IVL, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_RECOVERY_IVL);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_RECOVERY_IVL) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_RECOVERY_IVL: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = 3;
/* socket option is marked mode="rw" type=int64 php_type=int */
if (defined ("ZMQ::SOCKOPT_RECOVERY_IVL_MSEC") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_RECOVERY_IVL_MSEC, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_RECOVERY_IVL_MSEC);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_RECOVERY_IVL_MSEC) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_RECOVERY_IVL_MSEC: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = 3;
/* socket option is marked mode="rw" type=int64 php_type=int */
if (defined ("ZMQ::SOCKOPT_MCAST_LOOP") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_MCAST_LOOP, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_MCAST_LOOP);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_MCAST_LOOP) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_MCAST_LOOP: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_RCVTIMEO") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_RCVTIMEO, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_RCVTIMEO);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_RCVTIMEO) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_RCVTIMEO: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_SNDTIMEO") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_SNDTIMEO, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_SNDTIMEO);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_SNDTIMEO) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_SNDTIMEO: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=uint64 php_type=int */
if (defined ("ZMQ::SOCKOPT_SNDBUF") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_SNDBUF, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_SNDBUF);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_SNDBUF) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_SNDBUF: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=uint64 php_type=int */
if (defined ("ZMQ::SOCKOPT_RCVBUF") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_RCVBUF, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_RCVBUF);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_RCVBUF) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_RCVBUF: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_LINGER") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_LINGER, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_LINGER);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_LINGER) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_LINGER: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_RECONNECT_IVL") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_RECONNECT_IVL, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_RECONNECT_IVL);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_RECONNECT_IVL) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_RECONNECT_IVL: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_RECONNECT_IVL_MAX") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_RECONNECT_IVL_MAX, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_RECONNECT_IVL_MAX);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_RECONNECT_IVL_MAX) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_RECONNECT_IVL_MAX: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_BACKLOG") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_BACKLOG, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_BACKLOG);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_BACKLOG) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_BACKLOG: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="w" type=string php_type=string */
if (defined ("ZMQ::SOCKOPT_SUBSCRIBE") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = "test";

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test write-only
    $socket->setSockOpt(ZMQ::SOCKOPT_SUBSCRIBE, $test_value);
    $tested++;

    try {
        $socket->getSockOpt(ZMQ::SOCKOPT_SUBSCRIBE);
        echo "Should not be able to get ZMQ::SOCKOPT_SUBSCRIBE" . PHP_EOL;
    } catch (ZMQSocketException $e) {}

}
$removedVersion = false;
/* socket option is marked mode="w" type=string php_type=string */
if (defined ("ZMQ::SOCKOPT_UNSUBSCRIBE") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = "test";

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test write-only
    $socket->setSockOpt(ZMQ::SOCKOPT_UNSUBSCRIBE, $test_value);
    $tested++;

    try {
        $socket->getSockOpt(ZMQ::SOCKOPT_UNSUBSCRIBE);
        echo "Should not be able to get ZMQ::SOCKOPT_UNSUBSCRIBE" . PHP_EOL;
    } catch (ZMQSocketException $e) {}

}
$removedVersion = false;
/* socket option is marked mode="r" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_TYPE") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-only
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_TYPE);
    if (is_int($retval) === false) {
        echo "Incorrect return type for ZMQ::SOCKOPT_TYPE: expected=[int] actual=[" .gettype($retval). "]" . PHP_EOL;
    }
    $tested++;

    try {
        $socket->setSockOpt(ZMQ::SOCKOPT_TYPE, 'x');
        echo "Should not be able to set ZMQ::SOCKOPT_TYPE" . PHP_EOL;
    } catch (ZMQSocketException $e) {}

}
$removedVersion = false;
/* socket option is marked mode="r" type=int64 php_type=int */
if (defined ("ZMQ::SOCKOPT_RCVMORE") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-only
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_RCVMORE);
    if (is_int($retval) === false) {
        echo "Incorrect return type for ZMQ::SOCKOPT_RCVMORE: expected=[int] actual=[" .gettype($retval). "]" . PHP_EOL;
    }
    $tested++;

    try {
        $socket->setSockOpt(ZMQ::SOCKOPT_RCVMORE, 'x');
        echo "Should not be able to set ZMQ::SOCKOPT_RCVMORE" . PHP_EOL;
    } catch (ZMQSocketException $e) {}

}
$removedVersion = false;
/* socket option is marked mode="r" type=socket php_type=resource */
if (defined ("ZMQ::SOCKOPT_FD") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-only
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_FD);
    if (is_resource($retval) === false) {
        echo "Incorrect return type for ZMQ::SOCKOPT_FD: expected=[resource] actual=[" .gettype($retval). "]" . PHP_EOL;
    }
    $tested++;

    try {
        $socket->setSockOpt(ZMQ::SOCKOPT_FD, 'x');
        echo "Should not be able to set ZMQ::SOCKOPT_FD" . PHP_EOL;
    } catch (ZMQSocketException $e) {}

}
$removedVersion = false;
/* socket option is marked mode="r" type=uint32 php_type=int */
if (defined ("ZMQ::SOCKOPT_EVENTS") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-only
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_EVENTS);
    if (is_int($retval) === false) {
        echo "Incorrect return type for ZMQ::SOCKOPT_EVENTS: expected=[int] actual=[" .gettype($retval). "]" . PHP_EOL;
    }
    $tested++;

    try {
        $socket->setSockOpt(ZMQ::SOCKOPT_EVENTS, 'x');
        echo "Should not be able to set ZMQ::SOCKOPT_EVENTS" . PHP_EOL;
    } catch (ZMQSocketException $e) {}

}

if ($tested == 0) {
    echo "Did not test any constants" . PHP_EOL;
}
echo "OK";
--EXPECT--
OK

PK&��\
��"�"tests/libzmq3-sockopt.phptnu�[���--TEST--
Test setting socket options
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
if (!defined('ZMQ::LIBZMQ_VERSION_MAJOR') || ZMQ::LIBZMQ_VERSION_MAJOR < 3) {
    die ("skip This test is for PHP7 and libzmq version 3.x and up");
}
?>
--FILE--
<?php

$tested = 0;

$removedVersion = false;
/* socket option is marked mode="rw" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_SNDHWM") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_PUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_SNDHWM, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_SNDHWM);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_SNDHWM) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_SNDHWM: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_RCVHWM") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_RCVHWM, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_RCVHWM);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_RCVHWM) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_RCVHWM: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=int64 php_type=int */
if (defined ("ZMQ::SOCKOPT_MAXMSGSIZE") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_MAXMSGSIZE, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_MAXMSGSIZE);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_MAXMSGSIZE) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_MAXMSGSIZE: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_MULTICAST_HOPS") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_MULTICAST_HOPS, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_MULTICAST_HOPS);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_MULTICAST_HOPS) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_MULTICAST_HOPS: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="w" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_XPUB_VERBOSE") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_XPUB);

    // Test write-only
    $socket->setSockOpt(ZMQ::SOCKOPT_XPUB_VERBOSE, $test_value);
    $tested++;

    try {
        $socket->getSockOpt(ZMQ::SOCKOPT_XPUB_VERBOSE);
        echo "Should not be able to get ZMQ::SOCKOPT_XPUB_VERBOSE" . PHP_EOL;
    } catch (ZMQSocketException $e) {}

}
$removedVersion = false;
/* socket option is marked mode="rw" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_TCP_KEEPALIVE") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_TCP_KEEPALIVE, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_TCP_KEEPALIVE);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_TCP_KEEPALIVE) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_TCP_KEEPALIVE: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_TCP_KEEPALIVE_IDLE") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_TCP_KEEPALIVE_IDLE, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_TCP_KEEPALIVE_IDLE);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_TCP_KEEPALIVE_IDLE) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_TCP_KEEPALIVE_IDLE: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_TCP_KEEPALIVE_CNT") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_TCP_KEEPALIVE_CNT, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_TCP_KEEPALIVE_CNT);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_TCP_KEEPALIVE_CNT) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_TCP_KEEPALIVE_CNT: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_TCP_KEEPALIVE_INTVL") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_TCP_KEEPALIVE_INTVL, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_TCP_KEEPALIVE_INTVL);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_TCP_KEEPALIVE_INTVL) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_TCP_KEEPALIVE_INTVL: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="w" type=string php_type=string */
if (defined ("ZMQ::SOCKOPT_TCP_ACCEPT_FILTER") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = "127.0.0.1";

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test write-only
    $socket->setSockOpt(ZMQ::SOCKOPT_TCP_ACCEPT_FILTER, $test_value);
    $tested++;

    try {
        $socket->getSockOpt(ZMQ::SOCKOPT_TCP_ACCEPT_FILTER);
        echo "Should not be able to get ZMQ::SOCKOPT_TCP_ACCEPT_FILTER" . PHP_EOL;
    } catch (ZMQSocketException $e) {}

}
$removedVersion = false;
/* socket option is marked mode="r" type=string php_type=string */
if (defined ("ZMQ::SOCKOPT_LAST_ENDPOINT") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = "test";

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-only
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_LAST_ENDPOINT);
    if (is_string($retval) === false) {
        echo "Incorrect return type for ZMQ::SOCKOPT_LAST_ENDPOINT: expected=[string] actual=[" .gettype($retval). "]" . PHP_EOL;
    }
    $tested++;

    try {
        $socket->setSockOpt(ZMQ::SOCKOPT_LAST_ENDPOINT, 'x');
        echo "Should not be able to set ZMQ::SOCKOPT_LAST_ENDPOINT" . PHP_EOL;
    } catch (ZMQSocketException $e) {}

}
$removedVersion = false;
/* socket option is marked mode="w" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_ROUTER_RAW") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_ROUTER);

    // Test write-only
    $socket->setSockOpt(ZMQ::SOCKOPT_ROUTER_RAW, $test_value);
    $tested++;

    try {
        $socket->getSockOpt(ZMQ::SOCKOPT_ROUTER_RAW);
        echo "Should not be able to get ZMQ::SOCKOPT_ROUTER_RAW" . PHP_EOL;
    } catch (ZMQSocketException $e) {}

}
$removedVersion = false;
/* socket option is marked mode="rw" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_IPV4ONLY") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_IPV4ONLY, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_IPV4ONLY);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_IPV4ONLY) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_IPV4ONLY: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}

if ($tested == 0) {
    echo "Did not test any constants" . PHP_EOL;
}
echo "OK";
--EXPECT--
OK

PK&��\d*Omwwtests/054-curvekeypair.phptnu�[���--TEST--
Test curve keypair
--SKIPIF--
<?php
	require_once(dirname(__FILE__) . '/skipif.inc');
	if (!in_array ('curvekeypair', get_class_methods ('zmq')))
		die ('skip curvekeypair not found in libzmq');
?>
--FILE--
<?php

function test_z85_decode_encode($input) {

	$decoded = zmq::z85decode($input);
	$encoded = zmq::z85encode($decoded);

	if ($input !== $encoded) {
		echo "E: test_z85_decode_encode: input=[$input] encoded=[$encoded] decoded=[$decoded]" . PHP_EOL;
	}
}

$keypair = ZMQ::curveKeypair();

test_z85_decode_encode($keypair['public_key']);
test_z85_decode_encode($keypair['secret_key']);


echo "OK";

--EXPECT--
OKPK&��\=�g��tests/031-lastendpoint.phptnu�[���--TEST--
Test last endpoint
--SKIPIF--
<?php 
    require_once(dirname(__FILE__) . '/skipif.inc'); 
    if(!defined('ZMQ::SOCKOPT_LAST_ENDPOINT')) die('skip');
?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$context = new ZMQContext();
$server  = $context->getSocket(ZMQ::SOCKET_REP)
                   ->bind("inproc://hello-there");
$endpoint = $server->getSockopt(ZMQ::SOCKOPT_LAST_ENDPOINT);

var_dump($endpoint);

echo "OK";

--EXPECT--
string(20) "inproc://hello-there"
OKPK&��\�"��tests/032-contextopt.phptnu�[���--TEST--
Test context options
--SKIPIF--
<?php 
    require_once(dirname(__FILE__) . '/skipif.inc'); 
    if(!defined('ZMQ::CTXOPT_MAX_SOCKETS')) die('skip');
?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$context = new ZMQContext();

var_dump($context->getOpt(ZMQ::CTXOPT_MAX_SOCKETS) === ZMQ::CTXOPT_MAX_SOCKETS_DEFAULT);
var_dump($context->setOpt(ZMQ::CTXOPT_MAX_SOCKETS, 512));
var_dump($context->getOpt(ZMQ::CTXOPT_MAX_SOCKETS));

echo "OK";

--EXPECT--
bool(true)
NULL
int(512)
OKPK&��\�d�'MMtests/027-getset.phptnu�[���--TEST--
Test setting and getting values
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

$context = new ZMQContext();
$socket = $context->getSocket(ZMQ::SOCKET_DEALER);

$socket->setSockOpt (ZMQ::SOCKOPT_IDENTITY, "Hello");
var_dump ($socket->getSockOpt (ZMQ::SOCKOPT_IDENTITY));

$socket->setSockOpt (ZMQ::SOCKOPT_BACKLOG, 100);
var_dump ($socket->getSockOpt (ZMQ::SOCKOPT_BACKLOG));

$socket->setSockOpt (ZMQ::SOCKOPT_LINGER, 50);
var_dump ($socket->getSockOpt (ZMQ::SOCKOPT_LINGER));

echo "OK\n";

--EXPECTF--
string(5) "Hello"
int(100)
int(50)
OK
PK&��\m�|��tests/051-socketcount.phptnu�[���--TEST--
Test socket count variations
--SKIPIF--
<?php
	require_once(dirname(__FILE__) . '/skipif.inc'); 
	if (!in_array ('acquire', get_class_methods ('ZMQContext')))
		die ('skip');
	if (!in_array ('getsocketcount', get_class_methods ('ZMQContext')))
		die ('skip');
?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$context = new ZMQContext(1, false);

$socket1 = new ZMQSocket($context, ZMQ::SOCKET_REP);
$socket2 = $context->getSocket(ZMQ::SOCKET_REQ, 'persistent id');

var_dump ($context->getSocketCount());

unset($socket1);
var_dump ($context->getSocketCount());

unset($socket2);
var_dump ($context->getSocketCount());


$context = new ZMQContext(7, true);

$socket1 = new ZMQSocket($context, ZMQ::SOCKET_REP);
$socket2 = $context->getSocket(ZMQ::SOCKET_REQ, 'persistent id');

var_dump ($context->getSocketCount());

unset($socket1);
var_dump ($context->getSocketCount());

// Persistent socket should stay in count
unset($socket2);
var_dump ($context->getSocketCount());

$context = ZMQContext::acquire();

$socket1 = new ZMQSocket($context, ZMQ::SOCKET_REP);
$socket2 = $context->getSocket(ZMQ::SOCKET_REQ, 'persistent id');

var_dump ($context->getSocketCount());

unset($socket1);
var_dump ($context->getSocketCount());

// Persistent socket should stay in count
unset($socket2);
var_dump ($context->getSocketCount());

echo "OK";

--EXPECT--
int(2)
int(1)
int(0)
int(2)
int(1)
int(1)
int(2)
int(1)
int(1)
OKPK&��\ť�tests/bug_gh_165.phptnu�[���--TEST--
Test for Github issue #165
--SKIPIF--
<?php 
    require_once(dirname(__FILE__) . '/skipif.inc');
?>
--FILE--
<?php

$context = new ZMQContext (1, false);
$server = new ZMQSocket ($context, ZMQ::SOCKET_PUB);
$server->bind ('inproc://test');

$fd = $server->getSockOpt(ZMQ::SOCKOPT_FD);

$read   = array($fd);
$write  = NULL;
$except = NULL;
stream_select($read, $write, $except, 0);

echo "OK";
?>
--EXPECT--
OK
PK&��\{[Q��tests/001-send.phptnu�[���--TEST--
Test send / recv
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$server = create_server();
$client = create_client();

$client->sendmsg("Hello world!");

$message = $server->recvmsg();
var_dump($message);
$server->sendmsg($message);

$message = $client->recvmsg();
var_dump($message);

--EXPECT--
string(12) "Hello world!"
string(12) "Hello world!"PK&��\�:3���tests/bug_gh_59_2.phptnu�[���--TEST--
Test for Github issue #59
--SKIPIF--
<?php 
    require_once(dirname(__FILE__) . '/skipif.inc');

	if (!extension_loaded ('pcntl'))
		die("skip");
?>
--FILE--
<?php

function forkRepWorker()
{
    $pid = pcntl_fork();
    if ($pid != 0) {
        return $pid;
    }

    $context = new ZMQContext();
    $rep = $context->getSocket(\ZMQ::SOCKET_REP);
    $rep->connect('ipc://test2.ipc');

    $msg = $rep->recv();
    $rep->send($msg.'bar');
    sleep(2);
    exit;
}

$context = new ZMQContext(1, false);
$dealer = $context->getSocket(ZMQ::SOCKET_DEALER);

$pids[] = forkRepWorker($dealer);
$pids[] = forkRepWorker($dealer);

$dealer->bind('ipc://test2.ipc');
sleep (1);

$dealer->sendmulti(array('A', '', 'foo'));
$dealer->sendmulti(array('B', '', 'bar'));

$msgs = array();
$msgs[] = $dealer->recvmulti();
$msgs[] = $dealer->recvmulti();

foreach ($pids as $pid) {
    pcntl_waitpid($pid, $status, WUNTRACED);
}

var_dump(count ($msgs));
echo "OK";

--EXPECT--
int(2)
OKPK&��\�{��tests/022-highwatermark.phptnu�[���--TEST--
Test that high-watermark works
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
if (!defined('ZMQ::SOCKOPT_LINGER'))
    die ("Skip Not compiled against new enough version");
?>
--FILE--
<?php

$readable = array();
$writable = array();

$poll = new ZMQPoll();
$ctx  = new ZMQContext();

$req = new ZMQSocket($ctx, ZMQ::SOCKET_REQ);
$req->setSockOpt(ZMQ::SOCKOPT_HWM, 1);
$req->setSockOpt(ZMQ::SOCKOPT_LINGER, 1);
$req->bind("tcp://127.0.0.1:44331");

$rep = new ZMQSocket($ctx, ZMQ::SOCKET_REP);
$rep->connect("tcp://127.0.0.1:44331");

$poll->add($req, ZMQ::POLL_OUT);

$poll->poll($readable, $writable, 1000);
var_dump($writable);

$req->sendmsg('x');

$poll->poll($readable, $writable, 1000);
var_dump($writable);

$rep->recvmsg ();
$rep->sendmsg('x');
$req->recvmsg();

$poll->poll($readable, $writable, 1000);
var_dump($writable);

echo "OK\n";

?>
--EXPECTF--
array(1) {
  [0]=>
  object(ZMQSocket)#3 (0) {
  }
}
array(0) {
}
array(1) {
  [0]=>
  object(ZMQSocket)#3 (0) {
  }
}
OKPK&��\cW��tests/024-versionconstant.phptnu�[���--TEST--
Test retrieving version
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

echo strlen(ZMQ::LIBZMQ_VER) > 0 && strpos(ZMQ::LIBZMQ_VER, ".") !== false ? "OK" : FAIL;

--EXPECT--
OKPK&��\kR(yytests/049-events.phptnu�[���--TEST--
Test events
--SKIPIF--
<?php
	require_once(dirname(__FILE__) . '/skipif.inc');
	if (!in_array ('monitor', get_class_methods ('zmqsocket')))
		die ('skip monitor not supported in libzmq or PHP version (required: libzmq 4.1.0+ / PHP7)');
?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$context = new ZMQContext();

$client = $context->getSocket(ZMQ::SOCKET_DEALER);
$client->monitor("inproc://socket-monitor");

$monitor = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_PAIR);
$monitor->connect("inproc://socket-monitor");

$server = $context->getSocket(ZMQ::SOCKET_DEALER);
$server->bind("tcp://*:5050");

$client->connect("tcp://127.0.0.1:5050");
$event = $monitor->recvEvent();
var_dump ($event, $event["event"] == ZMQ::EVENT_CONNECT_DELAYED);

$event = $monitor->recvEvent();
var_dump ($event, $event["event"] == ZMQ::EVENT_CONNECTED);

echo "OK";

--EXPECTF--
array(3) {
  ["event"]=>
  int(2)
  ["value"]=>
  int(%d)
  ["address"]=>
  string(20) "tcp://127.0.0.1:5050"
}
bool(true)
array(3) {
  ["event"]=>
  int(1)
  ["value"]=>
  int(%d)
  ["address"]=>
  string(20) "tcp://127.0.0.1:5050"
}
bool(true)
OKPK&��\CSL�RRtests/skipif.incnu�[���<?php

if (!extension_loaded("zmq")) {
    die("skip Extension not loaded");
}
?>
PK&��\�ņjjtests/028-xpub.phptnu�[���--TEST--
Test send / recv with XPUB and XSUB sockets
--SKIPIF--
<?php 
    require_once(dirname(__FILE__) . '/skipif.inc'); 
    if(!defined('ZMQ::SOCKET_XPUB')) die('skip');
    if (!defined('ZMQ::LIBZMQ_VERSION_MAJOR') || ZMQ::LIBZMQ_VERSION_MAJOR < 3) {
         die ("skip This test is for libzmq version 3.x and up");
    }
?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$context = new ZMQContext();
$server = new ZMQSocket($context, ZMQ::SOCKET_XPUB);
$server->bind(ZEROMQ_TEST_DSN);
$client = new ZMQSocket($context, ZMQ::SOCKET_SUB);
$client->setSockOpt(ZMQ::SOCKOPT_SUBSCRIBE, "Hel");
$client->connect(ZEROMQ_TEST_DSN);

var_dump(substr($server->recvmsg(), 1));
$server->sendmsg("Goodbye world!");
$server->sendmsg("Hello world!");

$message = $client->recvmsg();
var_dump($message);

--EXPECT--
string(3) "Hel"
string(12) "Hello world!"PK&��\�Sy�YYtests/023-failedcallback.phptnu�[���--TEST--
Test that failing callback does not add socket to plist
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

function throw_stuff($a, $b) 
{
	throw new Exception("failed");
}

function just_echo($a, $b) 
{
	echo "called just_echo\n";
}

$context = new ZMQContext();

try {
    $socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'test id', 'throw_stuff');
    echo "fail\n";
} catch (Exception $e) {
    echo "success\n";
}

try {
    $socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'test id', 'throw_stuff');
    echo "fail\n";
} catch (Exception $e) {
    echo "success\n";
}

try {
    $socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'test id', 'just_echo');
    echo "success\n";
} catch (Exception $e) {
    echo "fail\n";
}

echo "OK\n";
/**/

try {
    $socket = new ZMQSocket($context, ZMQ::SOCKET_PUSH, 'xx id', 'throw_stuff');
    echo "fail\n";
} catch (Exception $e) {
    echo "success\n";
}

try {
    $socket = new ZMQSocket($context, ZMQ::SOCKET_PUSH, 'xx id', 'throw_stuff');
    echo "fail\n";
} catch (Exception $e) {
    echo "success\n";
}

try {
    $socket = new ZMQSocket($context, ZMQ::SOCKET_PUSH, 'xx id', 'just_echo');
    echo "success\n";
} catch (Exception $e) {
    echo "fail\n";
}


echo "OK\n";

--EXPECTF--
success
success
called just_echo
success
OK
success
success
called just_echo
success
OK

PK&��\�U:H��tests/048-pollsetitems.phptnu�[���--TEST--
Test pollset items
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); 
	if (PHP_VERSION_ID < 70000) {
		die ("skip PHP7 only");
	}

?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$s = create_server();
$poll = new ZMQPoll();

/* Create PHP stream socket */
$socket_server = stream_socket_server("tcp://127.0.0.1:5858", $errno, $errstr);

if (!$socket_server) {
	echo "Failed to create socket server: {$errstr}" . PHP_EOL;
	exit (1);
}

$socket_client = stream_socket_client("tcp://127.0.0.1:5858", $errno, $errstr);

if (!$socket_client) {
	echo "Failed to create socket client: {$errstr}" . PHP_EOL;
	exit (1);
}

/* Accept the client connection */
$stream = stream_socket_accept ($socket_server);

$poll->add(create_client(), ZMQ::POLL_IN);
$poll->add($stream, ZMQ::POLL_IN);
$poll->add(create_client(), ZMQ::POLL_IN);

foreach ($poll->items() as $item) {
	unset($item);
}
var_dump($poll->items());
var_dump($poll->clear()->items());

echo "OK";

--EXPECTF--
array(3) {
  ["o:%s"]=>
  object(ZMQSocket)#%d (%d) {
  }
  ["r:%d"]=>
  resource(%d) of type (stream)
  ["o:%s"]=>
  object(ZMQSocket)#%d (%d) {
  }
}
array(0) {
}
OK
PK&��\�c;�tests/040-cert-clone.phptnu�[���--TEST--
Test a ZMQCert can be cloned.
--SKIPIF--
<?php

	require_once __DIR__ . '/skipif.inc';
	require_once __DIR__ . '/skipif-czmq2.inc';
--FILE--
<?php

$cert = new ZMQCert();
$clonedCert = clone $cert;

var_dump($cert->equals($clonedCert));
--EXPECT--
bool(true)
PK&��\Y�eetests/021-callbackwarning.phptnu�[���--TEST--
Test warning in callback
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

error_reporting(0);

function generate_warning($a, $b) 
{
	in_array(1, 1);
}

try {
    $socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'persistent_socket', 'generate_warning');
    // on PHP7 and lower
    $lastError = error_get_last();
    if(strpos($lastError['message'], 'in_array() expects parameter 2 to be array') !== false)
     	echo "OK\n";
    else{
        echo "FAIL\n";
        print_r($lastError);
    }
}catch(TypeError $e){
 	echo "OK\n"; // on PHP8
}
--EXPECT--
OK
PK&��\�(�F��tests/skipif-libzmq2.incnu�[���<?php
if (!defined('ZMQ::LIBZMQ_VERSION_MAJOR') || ZMQ::LIBZMQ_VERSION_MAJOR != 2) {
    die ("skip This test is for PHP7 and libzmq version 2.x");
}
?>

PK&��\h��Dtests/bug_gh_59.phptnu�[���--TEST--
Test for Github issue #59
--SKIPIF--
<?php 
    require_once(dirname(__FILE__) . '/skipif.inc');

	if (!extension_loaded ('pcntl'))
		die("skip");
?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';
$server = create_server();

// fork a child to execute cmd, in case it crashes
$pid = pcntl_fork();
if ($pid == -1)
{
	die('could not fork');
}
else if ($pid)
{
	// we are the parent
	pcntl_wait($status);
	$exitcode = pcntl_wexitstatus($status);
}
else
	exit(0);

echo "OK";


--EXPECT--
OKPK&��\d�-��tests/039-cert-equals.phptnu�[���--TEST--
Test two ZMQCerts can be tested for equality.
--SKIPIF--
<?php

	require_once __DIR__ . '/skipif.inc';
	require_once __DIR__ . '/skipif-czmq2.inc';

	$cert = new ZMQCert();
	if ($cert->getPublicTxt() === str_repeat("0", 40)) {
		// This means no curve
		die("skip No curve enabled in libczmq");
	}
--FILE--
<?php

$cert = new ZMQCert();
$newCert = new ZMQCert();

var_dump($cert->equals($cert));
var_dump($newCert->equals($cert));

--EXPECT--
bool(true)
bool(false)
PK&��\�҂�� tests/037-device-deprecated.phptnu�[���--TEST--
Test device deprecated args
--SKIPIF--
<?php 
    require_once(dirname(__FILE__) . '/skipif.inc'); 
?>
--FILE--
<?php

$ctx = new ZMQContext ();
$s1 = new ZMQSocket ($ctx, ZMQ::SOCKET_SUB);
$device = new ZMQDevice($s1, $ctx->getSocket(ZMQ::SOCKET_PUB));


// Setup callback and user data for callback
$device->setIdleTimeout (100);
$device->setIdleCallback (function ($user_data) { echo "Called: {$user_data}" . PHP_EOL; return false; }, "test");

// Run first time
$device->run ();

echo "OK";
?>
--EXPECTF--
Deprecated: ZMQDevice::setidlecallback(): The signature for setIdleCallback has changed, please update your code in %s on line %d
Called: test
OK
PK&��\y(5���tests/bug_gh_156.phptnu�[���--TEST--
Test for GitHub issue 156 (https://github.com/mkoppanen/php-zmq/issues/156)
--DESCRIPTION--
The ZMQ_ROUTER_MANDATORY socket option was introduced in ØMQ v3.2.1 but wasn't
included in the appropriate sections of options/sockopts.xml.

Test that the ZMQ_ROUTER_MANDATORY socket option can be set when using ØMQ
v3.2.1 or higher.
--SKIPIF--
<?php

require_once(__DIR__ . '/skipif.inc');

if (!defined('\\ZMQ::SOCKOPT_ROUTER_MANDATORY')) {
    die('skip');
}

--FILE--
<?php

$context = new ZMQContext();
$socket = $context->getSocket(\ZMQ::SOCKET_ROUTER);
$socket->setSockOpt(\ZMQ::SOCKOPT_ROUTER_MANDATORY, 1);

echo "OK";

--EXPECT--
OK
PK&��\�H�b��tests/006-sockopt.phptnu�[���--TEST--
Test getsockopt / setsockopt
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

if (!is_callable('ZMQ', 'getSockOpt'))
	die("skip zeromq 2.0.7 or higher required");

$test = create_server();

$test->setSockOpt(ZMQ::SOCKOPT_IDENTITY, "hello");
var_dump($test->getSockOpt(ZMQ::SOCKOPT_IDENTITY));

$test->setSockOpt(ZMQ::SOCKOPT_IDENTITY, str_repeat("a", 255));
var_dump(strlen($test->getSockOpt(ZMQ::SOCKOPT_IDENTITY)));

try {
	$test->setSockOpt(ZMQ::SOCKOPT_IDENTITY, str_repeat("a", 300));
	var_dump(strlen($test->getSockOpt(ZMQ::SOCKOPT_IDENTITY)));
} catch (ZMQSocketException $e) {
	echo "too long";
}

--EXPECT--
string(5) "hello"
int(255)
too long
PK&��\��"��#tests/012-pollsetremoveinvalid.phptnu�[���--TEST--
Test remove invalid id from ZMQPoll
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

$poll = new ZMQPoll();
$ctx  = new ZMQContext();
$sock = new ZMQSocket($ctx, ZMQ::SOCKET_REP);


$id1 = $poll->add(fopen(__FILE__, 'r'), ZMQ::POLL_IN);
$id2 = $poll->add($sock, ZMQ::POLL_IN);

$poll->remove($id1);
$poll->remove("adsads");

echo "OK";

--EXPECT--
OKPK&��\�x֬�tests/skipif-czmq2.incnu�[���<?php
	if (!class_exists('ZMQCert') || !class_exists('ZMQAuth')) {
		die('skip This test requires php-zmq to be compiled with --with-czmq (only CZMQ 2.x supported)');
	}
?>PK&��\ƒ_hoo"tests/016-callbackinvalidargs.phptnu�[���--TEST--
Test invalid args for callback
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

try {
	$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'my persistent 1', 'this_function_does_not_exist');
	echo "Fail\n";
} catch (ZMQSocketException $e) {
	echo "OK\n";
} catch (TypeError $e) {
 	echo "OK\n"; // on PHP8
}

try {
	$ctx = new ZMQContext();
	$socket = $ctx->getSocket(ZMQ::SOCKET_REQ, 'my persistent 2', 'this_function_does_not_exist');
	echo "Fail\n";
} catch (ZMQSocketException $e) {
	echo "OK\n";
} catch (TypeError $e) {
 	echo "OK\n"; // on PHP8
}

--EXPECT--
OK
OKPK&��\�ϡ� tests/013-pollclearandreuse.phptnu�[���--TEST--
Test clearing and reusing ZMQPoll
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

$poll = new ZMQPoll();
$ctx  = new ZMQContext();

for ($i = 0; $i < 10; $i++) {
    $id = $poll->add(new ZMQSocket($ctx, ZMQ::SOCKET_REP), ZMQ::POLL_IN);
    
}

var_dump($poll->count());
$poll->clear();
var_dump($poll->count());


for ($i = 0; $i < 10; $i++) {
    $ids[] = $poll->add(new ZMQSocket($ctx, ZMQ::SOCKET_REP, 'dfd'), ZMQ::POLL_IN);
}

var_dump($poll->count());

for ($i = 0; $i < 10; $i++) {
    if ($poll->remove($ids[$i]) !== true) {
        echo 'err';
    }
}
var_dump($poll->count());

--EXPECT--
int(10)
int(0)
int(10)
int(0)PK&��\0KKw

tests/044-auth-construct.phptnu�[���--TEST--
Test a ZMQAuth can be constructed.
--SKIPIF--
<?php
	require_once __DIR__ . '/skipif.inc';
	require_once __DIR__ . '/skipif-czmq2.inc';
--FILE--
<?php

$context = new ZMQContext();
$auth = new ZMQAuth($context);
var_dump((bool)$auth);
--EXPECT--
bool(true)
PK&��\�!�d		!tests/018-callbackpersistent.phptnu�[���--TEST--
Test callback arguments on persistent and non-persistent socket
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

function dump_args(ZMQSocket $s, $p = null) 
{
	var_dump($s, $p);
}

$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'persistent_socket', 'dump_args');
$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, null, 'dump_args');

echo "OK";

--EXPECTF--
object(ZMQSocket)#%d (0) {
}
string(17) "persistent_socket"
object(ZMQSocket)#%d (0) {
}
NULL
OKPK&��\Rde���tests/bug_gh_50.phptnu�[���--TEST--
Test for Github issue #50
--SKIPIF--
<?php 
    require_once(dirname(__FILE__) . '/skipif.inc'); 
?>
--FILE--
<?php

$context = new ZMQContext (1, false);
$server = new ZMQSocket ($context, ZMQ::SOCKET_PUB);
$server->bind ('inproc://test');

$client = new ZMQSocket ($context, ZMQ::SOCKET_SUB);
$client->setsockopt (ZMQ::SOCKOPT_SUBSCRIBE, "");
$client->connect ('inproc://test');

$client2 = new ZMQSocket ($context, ZMQ::SOCKET_SUB);
$client2->setsockopt (ZMQ::SOCKOPT_SUBSCRIBE, "");
$client2->connect ('inproc://test');

$poll = new ZMQPoll ();
$poll->add ($client, ZMQ::POLL_IN);
$poll->add ($client2, ZMQ::POLL_IN);

$readable = array();
$writable = array();

$server->send ("Hello all");

$res = $poll->poll ($readable, $writable, 1000);
var_dump ($poll->count () == $res, $readable, $writable);

foreach ($readable as $r)
    $r->recv ();
    
$poll->remove ($client2);
$server->send ("Hello all");

$res = $poll->poll ($readable, $writable, 1000);
var_dump ($poll->count () == $res, $readable, $writable);

?>

--EXPECT--
bool(true)
array(2) {
  [0]=>
  object(ZMQSocket)#3 (0) {
  }
  [1]=>
  object(ZMQSocket)#4 (0) {
  }
}
array(0) {
}
bool(true)
array(1) {
  [0]=>
  object(ZMQSocket)#3 (0) {
  }
}
array(0) {
}PK&��\]7/tests/053-z85.phptnu�[���--TEST--
Test z85
--SKIPIF--
<?php
	require_once(dirname(__FILE__) . '/skipif.inc');
	if (!in_array ('z85encode', get_class_methods ('zmq')))
		die ('skip z85encode not found in libzmq');
?>
--FILE--
<?php

function test_z85_encode_decode($input) {
	$encoded = zmq::z85encode($input);
	$decoded = zmq::z85decode($encoded);

	if ($input !== $decoded) {
		echo "E: test_z85_encode_decode: input=[$input] encoded=[$encoded] decoded=[$decoded]" . PHP_EOL;
	}
}

function test_z85_encode($input, $expect) {
	if ($expect !== zmq::z85encode($input)) {
		echo "E: test_z85_encode: input=[$input] expect=[$expect]" . PHP_EOL;
	}
}

function test_z85_decode($input, $expect) {
	if ($expect !== zmq::z85decode($input)) {
		echo "E: test_z85_decode: input=[$input] expect=[$expect]" . PHP_EOL;
	}
}

$file = file_get_contents(__DIR__ . '/rose.jpg');
test_z85_encode_decode(substr($file, 0, 128));
test_z85_encode_decode(substr($file, 128, 128));

for ($i = 4; $i <= 256; $i += 4) {
	$str = substr(str_shuffle(str_repeat("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", $i)), 0, $i);
	test_z85_encode_decode($str);
}

// Incorrect length
test_z85_encode('1234567', null);
test_z85_encode('', null);

test_z85_decode('1234567', null);
test_z85_decode('', null);

echo "OK";

--EXPECT--
OK
PK'��\���{��"tests/020-exceptionincallback.phptnu�[���--TEST--
Test throwing exception from callback
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

function this_throws($a, $b) 
{
	throw new Exception("Hello there");
}

try {
	$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'persistent_socket', 'this_throws');
	echo "Fail\n";
} catch (Exception $e) {
	echo $e->getMessage() . "\n";
}

--EXPECTF--
Hello there

PK'��\�ϪWWtests/030-xrepmanualqueue.phptnu�[���--TEST--
Test send / recv with a manually created XREQ and XREP device
--SKIPIF--
<?php 
    require_once(dirname(__FILE__) . '/skipif.inc'); 
    if(!defined('ZMQ::SOCKOPT_RCVLABEL')) die('skip Only for in libzmq 3.3.0');
?>
--FILE--
<?php

$ctx = new ZMQContext();
$req = new ZMQSocket($ctx, ZMQ::SOCKET_REQ);
$xrep = new ZMQSocket($ctx, ZMQ::SOCKET_XREP);
$xreq = new ZMQSocket($ctx, ZMQ::SOCKET_XREQ);
$rep = new ZMQSocket($ctx, ZMQ::SOCKET_REP);
$xrep->bind('inproc://xrep');
$xreq->bind('inproc://xreq');
$req->connect('inproc://xrep');
$rep->connect('inproc://xreq');
$in = array('hi', 'there');
$req->sendMulti($in);

do {
	$message = $xrep->recv();
	$more = $xrep->getSockOpt(ZMQ::SOCKOPT_RCVMORE);
	if( $xrep->getSockOpt( ZMQ::SOCKOPT_RCVLABEL ) ) {
		$xreq->send( $message, ZMQ::MODE_SNDLABEL );
	} else {
		$xreq->send( $message, $more ? ZMQ::MODE_SNDMORE : 0 );
	}
} while( $more );

$out = $rep->recvMulti();
assert($in == $out);

$rep->sendMulti(array("oh", "hello!"));

do {
	$message = $xreq->recv();
	$more = $xreq->getSockOpt(ZMQ::SOCKOPT_RCVMORE);
	if( $xreq->getSockOpt( ZMQ::SOCKOPT_RCVLABEL ) ) {
		$xrep->send( $message, ZMQ::MODE_SNDLABEL );
	} else {
		$xrep->send( $message, $more ? ZMQ::MODE_SNDMORE : 0 );
	}
} while( $more );

var_dump($req->recvMulti());



--EXPECT--
array(2) {
  [0]=>
  string(2) "oh"
  [1]=>
  string(6) "hello!"
}
PK'��\�Q���tests/047-auth-configure.phptnu�[���--TEST--
Test a ZMQAuth can be configured.
--SKIPIF--
<?php
	require_once __DIR__ . '/skipif.inc';
	require_once __DIR__ . '/skipif-czmq2.inc';
--FILE--
<?php

define('TEST_DIR', __DIR__ . '/tmp');
define('PASSWORDS_FILE', TEST_DIR . '/passwords');
define('CERTS_DIR', TEST_DIR . '/certs');
define('CERT_FILE', CERTS_DIR . '/cert');

if (!file_exists(TEST_DIR)) {
	mkdir(TEST_DIR);
}
if (!file_exists(CERTS_DIR)) {
	mkdir(CERTS_DIR);
}

$context = new ZMQContext();
$auth = new ZMQAuth($context);

// Test a ZMQAuth can be configured to use PLAIN authentication.
touch(PASSWORDS_FILE);
var_dump($auth->configure(ZMQAuth::AUTH_TYPE_PLAIN, '*', PASSWORDS_FILE) === $auth);
unlink(PASSWORDS_FILE);

// Test a ZMQAuth can be configured to use CURVE authentication.
$cert = new ZMQCert();
$cert->save(CERT_FILE);

var_dump($auth->configure(ZMQAuth::AUTH_TYPE_CURVE, '*', CERTS_DIR) === $auth);

// Test ZMQAuth#configure throws an exception when the auth type isn't
// recognised.
try {
	$auth->configure(-1, '*', CERTS_DIR);
} catch (ZMQAuthException $e) {
	var_dump($e->getMessage());
}

unlink(CERT_FILE);
unlink(CERT_FILE . '_secret');
rmdir(CERTS_DIR);
rmdir(TEST_DIR);
--EXPECT--
bool(true)
bool(true)
string(62) "Unknown auth type. Are you using one of the ZMQAuth constants?"
PK'��\�{�5��!tests/010-pollsetinvalidargs.phptnu�[���--TEST--
Test invalid args for ZMQPoll
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

try {
	$poll = new ZMQPoll();
	$poll->add('string here', 0);
} catch (ZMQPollException $e) {
	echo "Got exception\n";
}

try {
	$poll = new ZMQPoll();
	$poll->add(new stdClass(), 0);
} catch (ZMQPollException $e) {
	echo "Got second exception\n";
}

--EXPECT--
Got exception
Got second exceptionPK'��\�����!tests/008-twowaystoconstruct.phptnu�[���--TEST--
Test constructing a socket
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

/* First */
$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ);
var_dump($socket);

/* Second */
$ctx = new ZMQContext();
$socket2 = $ctx->getSocket(ZMQ::SOCKET_REQ);
var_dump($socket2);

--EXPECTF--
object(ZMQSocket)#%d (%d) {
}
object(ZMQSocket)#%d (%d) {
}PK'��\5�C33tests/046-cert-apply.phptnu�[���--TEST--
Test a ZMQCert can be applied to a ZMQSocket.
--SKIPIF--
<?php

	require_once __DIR__ . '/skipif.inc';
	require_once __DIR__ . '/skipif-czmq2.inc';
--FILE--
<?php

$context = new ZMQContext();
$socket = $context->getSocket(ZMQ::SOCKET_REQ);
$cert = new ZMQCert();
$cert->apply($socket);
--EXPECT--
PK'��\5����tests/bug_gh_49.phptnu�[���--TEST--
Test for Github issue #49
--SKIPIF--
<?php 
    require_once(dirname(__FILE__) . '/skipif.inc'); 
?>
--FILE--
<?php

$context = new ZMQContext (1, false);
$server = new ZMQSocket ($context, ZMQ::SOCKET_REP);
$server->bind ('inproc://test');

$client = new ZMQSocket ($context, ZMQ::SOCKET_REQ);
$client->connect ('inproc://test');

$poll = new ZMQPoll();

$poll->add ($server, ZMQ::POLL_IN);
$poll->add ($client, ZMQ::POLL_IN);

for ($i = 0; $i < 10; $i++)
{
    $readable = array();
    $writable = array();

    if ($i % 2)
    {
        $server->send ($i);
    }
    else
    {
        $client->send ($i);
    }
    $event = $poll->poll ($readable, $writable);

    if (!$event)
    {
        continue;
    }
    foreach ($readable as $socket)
    {
        $msg = $socket->recv();
        if ($socket === $server)
        {
            echo 'client to server msg:' . $msg . PHP_EOL;
        }
        else
        {
            echo 'server to client msg:' . $msg . PHP_EOL;
        }
    }
}
?>
--EXPECT--
client to server msg:0
server to client msg:1
client to server msg:2
server to client msg:3
client to server msg:4
server to client msg:5
client to server msg:6
server to client msg:7
client to server msg:8
server to client msg:9PK'��\n��77tests/042-cert-save.phptnu�[���--TEST--
Test a ZMQCert can be saved.
--SKIPIF--
<?php

	require_once __DIR__ . '/skipif.inc';
	require_once __DIR__ . '/skipif-czmq2.inc';
--FILE--
<?php

define('BASE_CERT_DIR', __DIR__ . '/certs');
mkdir(BASE_CERT_DIR);

// #save
$certPath = BASE_CERT_DIR . '/cert';

$cert = new ZMQCert();
$cert->save($certPath);
var_dump(is_file($certPath));
var_dump(is_file($certPath . '_secret'));

unlink($certPath);
unlink($certPath . '_secret');

// #savePublic
$certPath = BASE_CERT_DIR . '/cert_public';

$cert = new ZMQCert();
$cert->savePublic($certPath);
var_dump(is_file($certPath));

unlink($certPath);

// #saveSecret
$certPath = BASE_CERT_DIR . '/cert_secret';
$cert->saveSecret($certPath);
var_dump(is_file($certPath));

unlink($certPath);

rmdir(BASE_CERT_DIR);
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
PK'��\ʋ���tests/zeromq_test_helper.incnu�[���<?php

define('ZEROMQ_TEST_DSN', 'inproc://php-test');
define('ZEROMQ_TEST_DSN2', 'inproc://php-test-second');

function create_server($persistent_id = null) 
{
    $context = new ZMQContext();
    $server  = $context->getSocket(ZMQ::SOCKET_REP, $persistent_id)
                       ->bind(ZEROMQ_TEST_DSN);
    return $server;
}

function create_client($persistent_id = null) 
{
    $context = new ZMQContext();
    $client  = $context->getSocket(ZMQ::SOCKET_REQ, $persistent_id)
                       ->connect(ZEROMQ_TEST_DSN);

    return $client;
}

function bind_callback(ZMQSocket $socket, $persistent_id = null)
{
	static $port = 5566;

	$socket->bind(ZEROMQ_TEST_DSN . "-{$port}");
	$port++;
}PK'��\(	
tests/002-test-binary.phptnu�[���--TEST--
Test send / recv binary
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$rose = file_get_contents(dirname(__FILE__) . '/rose.jpg');

$server = create_server();
$client = create_client();

$client->sendmsg($rose);

$message = $server->recvmsg();
var_dump(strlen($message));

$server->sendmsg($message);

$message = $client->recvmsg();
var_dump(strlen($message));

var_dump($message === $rose);

--EXPECTF--
int(1580)
int(1580)
bool(true)PK'��\�t���tests/038-cert-construct.phptnu�[���--TEST--
Test a ZMQCert can be constructed.
--SKIPIF--
<?php
	require_once __DIR__ . '/skipif.inc';
	require_once __DIR__ . '/skipif-czmq2.inc';
--FILE--
<?php

$cert = new ZMQCert();
var_dump((bool)$cert);

date_default_timezone_set('Europe/London');
$dateTime = new DateTime();

try {
	$cert = new ZMQCert($dateTime);
} catch (ZMQCertException $e) {
	var_dump($e->getMessage());
}
--EXPECT--
bool(true)
string(69) "ZMQCert::__construct() expects parameter 1 to be string, object given"
PK'��\iq|��tests/011-exceptions.phptnu�[���--TEST--
Test exceptions
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

try {
	throw new ZMQContextException();
} catch (ZMQException $e) {
	echo "1 catched\n";
}

try {
	throw new ZMQSocketException();
} catch (ZMQException $e) {
	echo "2 catched\n";
}

try {
	throw new ZMQPollException();
} catch (ZMQException $e) {
	echo "3 catched\n";
}

--EXPECT--
1 catched
2 catched
3 catchedPK'��\�O!�sstests/045-auth-allow-deny.phptnu�[���--TEST--
Test a ZMQAuth can whitelist or blacklist an IP address.
--SKIPIF--
<?php
	require_once __DIR__ . '/skipif.inc';
	require_once __DIR__ . '/skipif-czmq2.inc';
--FILE--
<?php

$context = new ZMQContext();
$auth = new ZMQAuth($context);
var_dump($auth->allow('127.0.0.1') === $auth);
var_dump($auth->deny('192.168.0.1') === $auth);
--EXPECT--
bool(true)
bool(true)
PK'��\mQ9צ�tests/034-unbind.phptnu�[���--TEST--
Test unbind
--SKIPIF--
<?php 
    require_once(dirname(__FILE__) . '/skipif.inc'); 
	if (version_compare(ZMQ::LIBZMQ_VER, '4.1.0', '<')) {
		die("skip Unbind doesnt work well before libzqm 4.1.x");
	}
?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$s = create_server();

$endpoints = $s->getendpoints();
var_dump($endpoints);

foreach ($endpoints['bind'] as $dsn) {
	$s->unbind($dsn);
}

var_dump ($s->getendpoints());
echo "OK";

--EXPECT--
array(2) {
  ["connect"]=>
  array(0) {
  }
  ["bind"]=>
  array(1) {
    [0]=>
    string(17) "inproc://php-test"
  }
}
array(2) {
  ["connect"]=>
  array(0) {
  }
  ["bind"]=>
  array(0) {
  }
}
OKPK'��\k����tests/029-xrepxreqdevice.phptnu�[���--TEST--
Test send / recv with an XREQ and XREP device
--SKIPIF--
<?php 
    require_once(dirname(__FILE__) . '/skipif.inc'); 
?>
--FILE--
<?php

require dirname(__FILE__) . '/zeromq_test_helper.inc';

function idle_func($val)
{
  return false;
}

$context = new ZMQContext();

$upstream = new ZMQSocket($context, ZMQ::SOCKET_XREQ);
$upstream->bind(ZEROMQ_TEST_DSN);

$downstream = new ZMQSocket($context, ZMQ::SOCKET_XREP);
$downstream->bind(ZEROMQ_TEST_DSN2);

$device = new ZMQDevice($upstream, $downstream);
$device->setIdleCallback('idle_func', 100, 'test');

$server = new ZMQSocket($context, ZMQ::SOCKET_REP);
$server->connect(ZEROMQ_TEST_DSN);

$client = new ZMQSocket($context, ZMQ::SOCKET_REQ);
$client->connect(ZEROMQ_TEST_DSN2);

$client->sendmsg("Hello server!");
$device->run();
var_dump($server->recvmsg());

$server->sendmsg("Hello client!");
$device->run();
var_dump($client->recvmsg());

--EXPECT--
string(13) "Hello server!"
string(13) "Hello client!"
PK'��\����tests/033-disconnect.phptnu�[���--TEST--
Test disconnect
--SKIPIF--
<?php 
    require_once(dirname(__FILE__) . '/skipif.inc');

	if (!in_array ('disconnect', get_class_methods ('zmqsocket')))
		die ('skip disconnect not supported in libzmq version');
?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$s = create_server();
$c = create_client();
$endpoints = $c->getendpoints();
var_dump($endpoints);

foreach ($endpoints['connect'] as $dsn) {
	$c->disconnect($dsn);
}

var_dump ($c->getendpoints());
echo "OK";

--EXPECT--
array(2) {
  ["connect"]=>
  array(1) {
    [0]=>
    string(17) "inproc://php-test"
  }
  ["bind"]=>
  array(0) {
  }
}
array(2) {
  ["connect"]=>
  array(0) {
  }
  ["bind"]=>
  array(0) {
  }
}
OKPK'��\�SRRtests/052-pthreads.phptnu�[���--TEST--
Test pthreads integration
--SKIPIF--
<?php 
	require_once(dirname(__FILE__) . '/skipif.inc'); 
	if (!extension_loaded ('pthreads')) {
		die ('skip Requires pthreads extension');
	}
	if (!in_array ('acquire', get_class_methods ('ZMQContext')))
		die ('skip');
	if (!in_array ('getsocketcount', get_class_methods ('ZMQContext')))
		die ('skip');
?>
--FILE--
<?php

$threads = 10;

class MyWorker extends Thread {
	private $sendThisBack;

	public function __construct($sendThisBack){
		$this->sendThisBack = $sendThisBack;
	}

	public function run() {
		$context = ZMQContext::acquire();
		$socket = $context->getSocket(ZMQ::SOCKET_PUSH);
		$socket->connect ("inproc://pthreads-test");
		$socket->send($this->sendThisBack);
		usleep(500 * 1000);
	}
}

class MyServer extends Thread {
	private $threads;
	
	public function __construct($threads){
		$this->threads = $threads;
	}
	
	public function run() {
		$context = ZMQContext::acquire();
		$socket = $context->getSocket(ZMQ::SOCKET_PULL);
		$socket->bind("inproc://pthreads-test");
		$socket->setSockOpt(ZMQ::SOCKOPT_HWM, 1000);
		usleep(500 * 1000);
		
		echo 'Receiving responses' . PHP_EOL;
		$responses = array();
		for ($i = 0; $i < $this->threads; $i++) {
			$responses[] = $socket->recv();
		}
		sort($responses);
		foreach($responses as $response){
			echo $response . PHP_EOL;
		}
	}
}

$server = new MyServer($threads);
$server->start();
echo 'Server started' . PHP_EOL;

$requests = array();
for ($i = 0; $i < $threads; $i++) {
	$requests[$i] = new MyWorker("thr_$i");
	$requests[$i]->start();
}
echo 'Workers started' . PHP_EOL;

for ($i = 0; $i < $threads; $i++) {
	$requests[$i]->join();
}
$server->join();
echo 'All requests pushed' . PHP_EOL;

echo "OK";

--EXPECT--
Server started
Workers started
Receiving responses
thr_0
thr_1
thr_2
thr_3
thr_4
thr_5
thr_6
thr_7
thr_8
thr_9
All requests pushed
OKPK'��\�
X�55tests/libzmq4-sockopt.phptnu�[���--TEST--
Test setting socket options
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
if (!defined('ZMQ::LIBZMQ_VERSION_MAJOR') || ZMQ::LIBZMQ_VERSION_MAJOR < 4) {
    die ("skip This test is for PHP7 and libzmq version 4.x and up");
}
?>
--FILE--
<?php

$tested = 0;

$removedVersion = false;
/* socket option is marked mode="w" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_ROUTER_MANDATORY") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_ROUTER);

    // Test write-only
    $socket->setSockOpt(ZMQ::SOCKOPT_ROUTER_MANDATORY, $test_value);
    $tested++;

    try {
        $socket->getSockOpt(ZMQ::SOCKOPT_ROUTER_MANDATORY);
        echo "Should not be able to get ZMQ::SOCKOPT_ROUTER_MANDATORY" . PHP_EOL;
    } catch (ZMQSocketException $e) {}

}
$removedVersion = false;
/* socket option is marked mode="w" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_PROBE_ROUTER") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_DEALER);

    // Test write-only
    $socket->setSockOpt(ZMQ::SOCKOPT_PROBE_ROUTER, $test_value);
    $tested++;

    try {
        $socket->getSockOpt(ZMQ::SOCKOPT_PROBE_ROUTER);
        echo "Should not be able to get ZMQ::SOCKOPT_PROBE_ROUTER" . PHP_EOL;
    } catch (ZMQSocketException $e) {}

}
$removedVersion = false;
/* socket option is marked mode="w" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_REQ_RELAXED") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_REQ);

    // Test write-only
    $socket->setSockOpt(ZMQ::SOCKOPT_REQ_RELAXED, $test_value);
    $tested++;

    try {
        $socket->getSockOpt(ZMQ::SOCKOPT_REQ_RELAXED);
        echo "Should not be able to get ZMQ::SOCKOPT_REQ_RELAXED" . PHP_EOL;
    } catch (ZMQSocketException $e) {}

}
$removedVersion = false;
/* socket option is marked mode="w" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_REQ_CORRELATE") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_REQ);

    // Test write-only
    $socket->setSockOpt(ZMQ::SOCKOPT_REQ_CORRELATE, $test_value);
    $tested++;

    try {
        $socket->getSockOpt(ZMQ::SOCKOPT_REQ_CORRELATE);
        echo "Should not be able to get ZMQ::SOCKOPT_REQ_CORRELATE" . PHP_EOL;
    } catch (ZMQSocketException $e) {}

}
$removedVersion = false;
/* socket option is marked mode="w" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_CONFLATE") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_PUSH);

    // Test write-only
    $socket->setSockOpt(ZMQ::SOCKOPT_CONFLATE, $test_value);
    $tested++;

    try {
        $socket->getSockOpt(ZMQ::SOCKOPT_CONFLATE);
        echo "Should not be able to get ZMQ::SOCKOPT_CONFLATE" . PHP_EOL;
    } catch (ZMQSocketException $e) {}

}
$removedVersion = false;
/* socket option is marked mode="rw" type=string php_type=string */
if (defined ("ZMQ::SOCKOPT_ZAP_DOMAIN") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = "test";

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_ZAP_DOMAIN, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_ZAP_DOMAIN);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_ZAP_DOMAIN) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_ZAP_DOMAIN: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="r" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_MECHANISM") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-only
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_MECHANISM);
    if (is_int($retval) === false) {
        echo "Incorrect return type for ZMQ::SOCKOPT_MECHANISM: expected=[int] actual=[" .gettype($retval). "]" . PHP_EOL;
    }
    $tested++;

    try {
        $socket->setSockOpt(ZMQ::SOCKOPT_MECHANISM, 'x');
        echo "Should not be able to set ZMQ::SOCKOPT_MECHANISM" . PHP_EOL;
    } catch (ZMQSocketException $e) {}

}
$removedVersion = false;
/* socket option is marked mode="rw" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_PLAIN_SERVER") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_PUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_PLAIN_SERVER, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_PLAIN_SERVER);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_PLAIN_SERVER) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_PLAIN_SERVER: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=string php_type=string */
if (defined ("ZMQ::SOCKOPT_PLAIN_USERNAME") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = "test";

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_PLAIN_USERNAME, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_PLAIN_USERNAME);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_PLAIN_USERNAME) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_PLAIN_USERNAME: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=string php_type=string */
if (defined ("ZMQ::SOCKOPT_PLAIN_PASSWORD") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = "test";

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_PLAIN_PASSWORD, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_PLAIN_PASSWORD);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_PLAIN_PASSWORD) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_PLAIN_PASSWORD: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_IPV6") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_IPV6, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_IPV6);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_IPV6) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_IPV6: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}
$removedVersion = false;
/* socket option is marked mode="rw" type=int php_type=int */
if (defined ("ZMQ::SOCKOPT_IMMEDIATE") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) {
    $test_value = 1;

    $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_DEALER);

    // Test read-write
    $socket->setSockOpt(ZMQ::SOCKOPT_IMMEDIATE, $test_value);
    $retval = $socket->getSockOpt(ZMQ::SOCKOPT_IMMEDIATE);

    if ($socket->getSockOpt(ZMQ::SOCKOPT_IMMEDIATE) !== $test_value) {
        echo "Failed to set ZMQ::SOCKOPT_IMMEDIATE: expected=[$test_value] actual=[$retval]" . PHP_EOL;
    }
    $tested++;


}

if ($tested == 0) {
    echo "Did not test any constants" . PHP_EOL;
}
echo "OK";
--EXPECT--
OK

PK'��\�=wwtests/005-forceconnectarg.phptnu�[���--TEST--
Test forcing connect
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ);
$socket->connect("tcp://127.0.0.1:5566");
$socket->connect("tcp://127.0.0.1:5566", true);
$socket->connect("tcp://127.0.0.1:5566", true);
$socket->connect("tcp://127.0.0.1:5566", true);
$socket->connect("tcp://127.0.0.1:5566");

var_dump($socket->getEndpoints());

--EXPECTF--
array(2) {
  ["connect"]=>
  array(1) {
    [0]=>
    string(20) "tcp://127.0.0.1:5566"
  }
  ["bind"]=>
  array(0) {
  }
}PK'��\�ؚ�tests/skipif-libzmq4.incnu�[���<?php
if (!defined('ZMQ::LIBZMQ_VERSION_MAJOR') || ZMQ::LIBZMQ_VERSION_MAJOR != 4) {
    die ("skip This test is for PHP7 and libzmq version 4.x");
}
?>

PK'��\n� ��tests/004-getendpoints.phptnu�[���--TEST--
Test getting endpoints
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$server = create_server();
$client = create_client();

var_dump($client->getEndpoints());
var_dump($server->getEndpoints());

$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ);
var_dump($socket->getEndpoints());

--EXPECTF--
array(2) {
  ["connect"]=>
  array(1) {
    [0]=>
    string(%d) "inproc://php-test"
  }
  ["bind"]=>
  array(0) {
  }
}
array(2) {
  ["connect"]=>
  array(0) {
  }
  ["bind"]=>
  array(1) {
    [0]=>
    string(%d) "inproc://php-test"
  }
}
array(2) {
  ["connect"]=>
  array(0) {
  }
  ["bind"]=>
  array(0) {
  }
}PK'��\S0�WWtests/014-setsockoptparam.phptnu�[���--TEST--
Test setSockOpt param type
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php

$poll = new ZMQPoll();
$ctx  = new ZMQContext();
$sock = new ZMQSocket($ctx, ZMQ::SOCKET_REP);

$test = "1";

$sock->setSockOpt(ZMQ::SOCKOPT_HWM, $test);
echo gettype($test) . "\n";

echo "done\n";


--EXPECT--
string
donePK'��\�����tests/036-device.phptnu�[���--TEST--
Test device callbacks
--SKIPIF--
<?php 
    require_once(dirname(__FILE__) . '/skipif.inc'); 
?>
--FILE--
<?php

function proper_microtime () {
    return round ((microtime (true) * 1000));
}

class CbStateData
{
	protected $_counter = 0;
	protected $_name;

	public function __construct ($name) {
	  $this->_name = $name;
	}

	public function getName () {
	  return $this->_name;
	}

	public function increment ()
	{
		return ++$this->_counter;
	}

	public function getCount () {
	  return $this->_counter;
	}

	public function reset () {
		$this->_counter = 0;
	}
}

class test {
	function foo ($user_data) {
		return false;
	}
}

$test = new test ();

$ctx = new ZMQContext ();
$device = new ZMQDevice($ctx->getSocket(ZMQ::SOCKET_SUB), $ctx->getSocket(ZMQ::SOCKET_PUB));

$last_called = proper_microtime ();
$user_data = new CbStateData ('timer');

$orig_cb = function ($user_data) use (&$last_called, $device) {
				echo "Triggered for {$device->getTimerTimeout ()}ms timeout" . PHP_EOL;

				$time_elapsed = (proper_microtime () - $last_called) + 1;

				if ($time_elapsed < $device->getTimerTimeout ()) {
					echo "Called too early, only {$time_elapsed}ms elapsed, expected {$device->getTimerTimeout ()}" . PHP_EOL;
				}

				$device->setTimerTimeout ($device->getTimerTimeout () + 50);
				$last_called = proper_microtime ();

				echo "{$user_data->getName ()} function called {$user_data->increment ()} times\n";
				return $user_data->getCount() < 3 ? true : false;
			};

// Setup callback and user data for callback
$device->setTimerCallback ($orig_cb, 100, $user_data);

// Run first time
$device->run ();

$device->setTimerCallback (array ($test, 'foo'), 100, $user_data);
$device->setTimerCallback (array ($test, 'foo'), 100, $user_data);
$device->setTimerCallback ($orig_cb, 100, $user_data);
sleep (1);

// Run second time
$user_data->reset ();
$device->setTimerTimeout (110);

$device->run ();

echo "OK";
?>
--EXPECT--
Triggered for 100ms timeout
timer function called 1 times
Triggered for 150ms timeout
timer function called 2 times
Triggered for 200ms timeout
timer function called 3 times
Triggered for 110ms timeout
timer function called 1 times
Triggered for 160ms timeout
timer function called 2 times
Triggered for 210ms timeout
timer function called 3 times
OK
PK'��\#r&���tests/050-sharedcontext.phptnu�[���--TEST--
Test shared context
--SKIPIF--
<?php
	require_once(dirname(__FILE__) . '/skipif.inc');
	if (!in_array ('acquire', get_class_methods ('ZMQContext')))
		die ('skip');
?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$context = ZMQContext::acquire();

$socket1 = new ZMQSocket($context, ZMQ::SOCKET_REP);
$socket2 = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_REQ, 'persistent id');

$dsn = uniqid("inproc://shared-ctx-");

$socket1->bind ($dsn);
$socket2->connect ($dsn);

$socket2->send("hello");
var_dump($socket1->recv());

var_dump ($context->isPersistent());
var_dump ($context->getSocketCount());

echo "OK";

--EXPECT--
string(5) "hello"
bool(true)
int(2)
OKPK&��\R����tests/bug_gh_43.phptnu�[���PK&��\|���tests/skipif-libzmq3.incnu�[���PK&��\��ĭ�tests/003-getpersistentid.phptnu�[���PK&��\�*͔996tests/007-addremovepoll.phptnu�[���PK&��\�x#����tests/009-ispersistent.phptnu�[���PK&��\�����tests/025-sendrecvmulti.phptnu�[���PK&��\��P����tests/015-callback.phptnu�[���PK&��\$��

�tests/026-sockettype.phptnu�[���PK&��\jl�%%%tests/035-capture.phptnu�[���PK&��\�u5,,�tests/rose.jpgnu�[���PK&��\���&�#tests/017-callbackonlyonnewsocket.phptnu�[���PK&��\!M��b'tests/041-cert-meta.phptnu�[���PK&��\1L�5���*tests/043-cert-load.phptnu�[���PK&��\9��T��a-tests/055-socks-proxy.phptnu�[���PK&��\TޤR9R9_1tests/libzmq2-sockopt.phptnu�[���PK&��\
��"�"�jtests/libzmq3-sockopt.phptnu�[���PK&��\d*Omww�tests/054-curvekeypair.phptnu�[���PK&��\=�g����tests/031-lastendpoint.phptnu�[���PK&��\�"���tests/032-contextopt.phptnu�[���PK&��\�d�'MM<�tests/027-getset.phptnu�[���PK&��\m�|��Ηtests/051-socketcount.phptnu�[���PK&��\ť���tests/bug_gh_165.phptnu�[���PK&��\{[Q����tests/001-send.phptnu�[���PK&��\�:3�����tests/bug_gh_59_2.phptnu�[���PK&��\�{��ͥtests/022-highwatermark.phptnu�[���PK&��\cW���tests/024-versionconstant.phptnu�[���PK&��\kR(yy:�tests/049-events.phptnu�[���PK&��\CSL�RR��tests/skipif.incnu�[���PK&��\�ņjj��tests/028-xpub.phptnu�[���PK&��\�Sy�YY7�tests/023-failedcallback.phptnu�[���PK&��\�U:H��ݹtests/048-pollsetitems.phptnu�[���PK&��\�c;�ľtests/040-cert-clone.phptnu�[���PK&��\Y�ee�tests/021-callbackwarning.phptnu�[���PK&��\�(�F����tests/skipif-libzmq2.incnu�[���PK&��\h��D��tests/bug_gh_59.phptnu�[���PK&��\d�-����tests/039-cert-equals.phptnu�[���PK&��\�҂�� �tests/037-device-deprecated.phptnu�[���PK&��\y(5����tests/bug_gh_156.phptnu�[���PK&��\�H�b����tests/006-sockopt.phptnu�[���PK&��\��"��#�tests/012-pollsetremoveinvalid.phptnu�[���PK&��\�x֬���tests/skipif-czmq2.incnu�[���PK&��\ƒ_hoo"��tests/016-callbackinvalidargs.phptnu�[���PK&��\�ϡ� ��tests/013-pollclearandreuse.phptnu�[���PK&��\0KKw

��tests/044-auth-construct.phptnu�[���PK&��\�!�d		!��tests/018-callbackpersistent.phptnu�[���PK&��\Rde���?�tests/bug_gh_50.phptnu�[���PK&��\]7/T�tests/053-z85.phptnu�[���PK'��\���{��"��tests/020-exceptionincallback.phptnu�[���PK'��\�ϪWW��tests/030-xrepmanualqueue.phptnu�[���PK'��\�Q���0�tests/047-auth-configure.phptnu�[���PK'��\�{�5��!|�tests/010-pollsetinvalidargs.phptnu�[���PK'��\�����!p�tests/008-twowaystoconstruct.phptnu�[���PK'��\5�C33E�tests/046-cert-apply.phptnu�[���PK'��\5������tests/bug_gh_49.phptnu�[���PK'��\n��77�tests/042-cert-save.phptnu�[���PK'��\ʋ���etests/zeromq_test_helper.incnu�[���PK'��\(	
rtests/002-test-binary.phptnu�[���PK'��\�t����tests/038-cert-construct.phptnu�[���PK'��\iq|��
tests/011-exceptions.phptnu�[���PK'��\�O!�ss�tests/045-auth-allow-deny.phptnu�[���PK'��\mQ9צ��
tests/034-unbind.phptnu�[���PK'��\k�����tests/029-xrepxreqdevice.phptnu�[���PK'��\�����tests/033-disconnect.phptnu�[���PK'��\�SRR�tests/052-pthreads.phptnu�[���PK'��\�
X�55ltests/libzmq4-sockopt.phptnu�[���PK'��\�=ww�>tests/005-forceconnectarg.phptnu�[���PK'��\�ؚ��Atests/skipif-libzmq4.incnu�[���PK'��\n� ���Btests/004-getendpoints.phptnu�[���PK'��\S0�WW�Etests/014-setsockoptparam.phptnu�[���PK'��\�����VGtests/036-device.phptnu�[���PK'��\#r&����Ptests/050-sharedcontext.phptnu�[���PKGG��S