Skip to content

Commit 58544c8

Browse files
authored
Merge pull request zeromq#208 from zebastian/master
updated to libzmq 4.17, socks proxy and some build tool cleanup
2 parents fc6e966 + 818ada4 commit 58544c8

13 files changed

+1153
-36
lines changed

DEVELOPERS.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## Build Instructions
2+
Run the following commands
3+
4+
```shell
5+
phpize && ./configure
6+
make
7+
make test
8+
```
9+
10+
see also http://wiki.zeromq.org/bindings:php
11+
12+
## Auto Generation
13+
14+
### Sockopts
15+
The ZMQ Lib functionality depends mostly on the sockopt flags which can be
16+
set on libzmq. In order to keep these flags in sync with the upstream
17+
library the flags can be automatically pulled by a script.
18+
19+
To do this you will need to install the gsl library, see also https://github.com/imatix/gsl
20+
21+
```shell
22+
git clone https://github.com/imatix/gsl
23+
cd gsl/src
24+
make
25+
sudo make install
26+
```
27+
28+
Then run from the project root directory `./options/generate.sh` to update
29+
the sockopts.
30+
31+
### api.php generation
32+
33+
The api definition can be auto generated by the tool DocThor.
34+
Note: This requires to build the extension first and specify on the command
35+
line.
36+
37+
```shell
38+
git clone https://github.com/SegFaulty/DocThor
39+
php -d extension=modules/zmq.so DocThor.php --sourceDir=./ zmq
40+
```

README.md

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
PHP bindings for 0MQ. The documentation is available at http://php.net/zmq
22

3-
The API is roughly as follows:
3+
[![Build Status](https://travis-ci.org/zeromq/php-zmq.png?branch=master)](https://travis-ci.org/zeromq/php-zmq)
44

5-
<?php
5+
The API is roughly as follows:
66

7-
/* Create new queue object */
8-
$queue = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, "MySock1");
7+
```php
8+
<?php
99

10-
/* Connect to an endpoint */
11-
$queue->connect("tcp://127.0.0.1:5555");
10+
/* Create new queue object */
11+
$queue = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, "MySock1");
1212

13-
/* send and receive */
14-
var_dump($queue->send("hello there, using socket 1")->recv());
13+
/* Connect to an endpoint */
14+
$queue->connect("tcp://127.0.0.1:5555");
1515

16-
?>
16+
/* send and receive */
17+
var_dump($queue->send("hello there, using socket 1")->recv());
1718

19+
?>
20+
```
1821

1922
For installation instructions see http://pecl.php.net/zmq
23+
24+
For developer instructions see DEVELOPERS.md

api.php

+150-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* zmq-API v@PACKAGE_VERSION@ Docs build by DocThor [2016-02-01]
3+
* zmq-API v@PACKAGE_VERSION@ Docs build by DocThor [2020-02-16]
44
* @package zmq
55
*/
66

@@ -30,18 +30,22 @@ class ZMQ {
3030
const MODE_NOBLOCK = 1;
3131
const MODE_DONTWAIT = 1;
3232
const ERR_INTERNAL = -99;
33-
const ERR_EAGAIN = 35;
34-
const ERR_ENOTSUP = 45;
33+
const ERR_EAGAIN = 11;
34+
const ERR_ENOTSUP = 95;
3535
const ERR_EFSM = 156384763;
3636
const ERR_ETERM = 156384765;
37-
const LIBZMQ_VER = '4.1.4';
38-
const LIBZMQ_VERSION = '4.1.4';
39-
const LIBZMQ_VERSION_ID = 40104;
37+
const LIBZMQ_VER = '4.1.7';
38+
const LIBZMQ_VERSION = '4.1.7';
39+
const LIBZMQ_VERSION_ID = 40107;
4040
const LIBZMQ_VERSION_MAJOR = 4;
4141
const LIBZMQ_VERSION_MINOR = 1;
42-
const LIBZMQ_VERSION_PATCH = 4;
42+
const LIBZMQ_VERSION_PATCH = 7;
4343
const SOCKOPT_TOS = 57;
4444
const SOCKOPT_ROUTER_HANDOVER = 56;
45+
const SOCKOPT_CONNECT_RID = 61;
46+
const SOCKOPT_HANDSHAKE_IVL = 66;
47+
const SOCKOPT_SOCKS_PROXY = 68;
48+
const SOCKOPT_XPUB_NODROP = 69;
4549
const SOCKOPT_ROUTER_MANDATORY = 33;
4650
const SOCKOPT_PROBE_ROUTER = 51;
4751
const SOCKOPT_REQ_RELAXED = 53;
@@ -109,6 +113,11 @@ class ZMQ {
109113
const EVENT_DISCONNECTED = 512;
110114
const EVENT_MONITOR_STOPPED = 1024;
111115
const EVENT_ALL = 65535;
116+
/**
117+
* A monotonic clock
118+
*
119+
* @return integer
120+
*/
112121
public function clock() {}
113122
public function z85encode($data) {}
114123
public function z85decode($data) {}
@@ -118,55 +127,177 @@ public function curvekeypair() {}
118127
* @package zmq
119128
*/
120129
class ZMQContext {
121-
public function __construct($io_threads = 1, $persistent = true) {}
130+
/**
131+
* Build a new ZMQContext object
132+
*
133+
* @param integer $io_threads
134+
* @param boolean $is_persistent
135+
* @return ZMQContext
136+
*/
137+
public function __construct($io_threads="", $persistent="") {}
138+
/**
139+
* Acquires a handle to the request global context
140+
*
141+
* @return ZMQContext
142+
*/
122143
public function acquire() {}
123144
public function getsocketcount() {}
124145
public function getsocket($type, $dsn, $on_new_socket="") {}
125146
public function ispersistent() {}
147+
/**
148+
* Set a context option
149+
*
150+
* @param int $option
151+
* @param int $value
152+
* @return ZMQContext
153+
*/
126154
public function setOpt($option, $value) {}
155+
/**
156+
* Set a context option
157+
*
158+
* @param int $option
159+
* @return ZMQContext
160+
*/
127161
public function getOpt($option) {}
128162
}
129163
/**
130164
* @package zmq
131165
*/
132166
class ZMQSocket {
133-
public function __construct(ZMQContext $ZMQContext, $type, $persistent_id=null, $on_new_socket=null) {}
134-
public function send($message, $mode=0) {}
167+
/**
168+
* Build a new ZMQSocket object
169+
*
170+
* @param ZMQContext $context
171+
* @param integer $type
172+
* @param string $persistent_id
173+
* @param callback $on_new_socket
174+
* @return ZMQSocket
175+
*/
176+
public function __construct(ZMQContext $ZMQContext, $type, $persistent_id="", $on_new_socket="") {}
177+
/**
178+
* Send a message. Return true if message was sent and false on EAGAIN
179+
*
180+
* @param string $message
181+
* @param integer $flags
182+
* @return ZMQSocket
183+
*/
184+
public function send($message, $mode="") {}
135185
public function recv($mode="") {}
136-
public function sendmulti($message, $mode=0) {}
137-
public function recvmulti($mode=0) {}
138-
public function bind($dsn, $force=false) {}
139-
public function connect($dsn, $force=false) {}
140-
public function monitor($dsn, $events=ZMQ::EVENT_ALL) {}
141-
public function recvevent($flags=0) {}
186+
/**
187+
* Send a multipart message. Return true if message was sent and false on EAGAIN
188+
*
189+
* @param arrays $messages
190+
* @param integer $flags
191+
* @return ZMQSocket
192+
*/
193+
public function sendmulti($message, $mode="") {}
194+
public function recvmulti($mode="") {}
195+
/**
196+
* Bind the socket to an endpoint
197+
*
198+
* @param string $dsn
199+
* @param boolean $force
200+
* @return ZMQSocket
201+
*/
202+
public function bind($dsn, $force="") {}
203+
/**
204+
* Connect the socket to an endpoint
205+
*
206+
* @param string $dsn
207+
* @param boolean $force
208+
* @return ZMQSocket
209+
*/
210+
public function connect($dsn, $force="") {}
211+
public function monitor($dsn, $events="") {}
212+
public function recvevent($flags="") {}
213+
/**
214+
* Unbind the socket from an endpoint
215+
*
216+
* @param string $dsn
217+
* @return ZMQSocket
218+
*/
142219
public function unbind($dsn) {}
220+
/**
221+
* Disconnect the socket from an endpoint
222+
*
223+
* @param string $dsn
224+
* @return ZMQSocket
225+
*/
143226
public function disconnect($dsn) {}
144227
public function setsockopt($key, $value) {}
145228
public function getendpoints() {}
146229
public function getsockettype() {}
147230
public function ispersistent() {}
148231
public function getpersistentid() {}
149232
public function getsockopt($key) {}
150-
public function sendmsg($message, $mode=0) {}
151-
public function recvmsg($mode=0) {}
233+
public function sendmsg($message, $mode="") {}
234+
public function recvmsg($mode="") {}
152235
}
153236
/**
154237
* @package zmq
155238
*/
156239
class ZMQPoll {
240+
/**
241+
* Add a ZMQSocket object into the pollset
242+
*
243+
* @param ZMQSocket $object
244+
* @param integer $events
245+
* @return integer
246+
*/
157247
public function add($entry, $type) {}
248+
/**
249+
* Poll the sockets
250+
*
251+
* @param array $readable
252+
* @param array $writable
253+
* @param integer $timeout
254+
* @return integer
255+
*/
158256
public function poll(&$readable, &$writable, $timeout="") {}
159257
public function getlasterrors() {}
258+
/**
259+
* Remove item from poll set
260+
*
261+
* @param mixed $item
262+
* @return boolean
263+
*/
160264
public function remove($remove) {}
265+
/**
266+
* Returns the number of items in the set
267+
*
268+
* @return integer
269+
*/
161270
public function count() {}
271+
/**
272+
* Clear the pollset
273+
*
274+
* @return ZMQPoll
275+
*/
162276
public function clear() {}
277+
/**
278+
* Clear the pollset
279+
*
280+
* @return array
281+
*/
163282
public function items() {}
164283
}
165284
/**
166285
* @package zmq
167286
*/
168287
class ZMQDevice {
169-
public function __construct(ZMQSocket $frontend, ZMQSocket $backend, ZMQSocket $capture=null) {}
288+
/**
289+
* Construct a device
290+
*
291+
* @param ZMQSocket $frontend
292+
* @param ZMQSocket $backend
293+
* @return void
294+
*/
295+
public function __construct(ZMQSocket $frontend, ZMQSocket $backend, ZMQSocket $capture="") {}
296+
/**
297+
* Start a device
298+
*
299+
* @return void
300+
*/
170301
public function run() {}
171302
public function setidlecallback($idle_callback, $timeout, $user_data="") {}
172303
public function setidletimeout($timeout) {}

options/README

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
In order to socket options:
1+
In order to autocreate the socket options:
22

33
1. install GSL from https://github.com/imatix/gsl
4-
2. run gsl -q sockopts.xml
4+
2. run gsl -q sockopts.xml
5+
6+
You may also directly run the script generate.sh inside this folder.

options/generate.sh

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ WGET=$(which wget)
44
GSL=$(which gsl)
55
GIT=$(which git)
66

7+
cd `dirname "$0"`
8+
79
if test "$WGET" = ""
810
then
911
echo "wget not found"
@@ -22,7 +24,12 @@ then
2224
exit 1
2325
fi
2426

25-
$WGET https://raw.githubusercontent.com/zeromq/czmq/master/src/sockopts.xml -O sockopts.xml
27+
# latest version supported
28+
$WGET https://raw.githubusercontent.com/zeromq/czmq/v4.0.0/src/sockopts.xml -O sockopts.xml
29+
30+
# not yet working
31+
# $WGET https://raw.githubusercontent.com/zeromq/czmq/master/src/sockopts.xml -O sockopts.xml
32+
2633
git diff sockopts.xml
2734

2835
$GSL -script:sockopts.gsl sockopts.xml

options/sockopts.gsl

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/*
99
+-----------------------------------------------------------------------------------+
1010
| ZMQ extension for PHP |
11-
| Copyright (c) 2010-2016, Mikko Koppanen <[email protected]> |
11+
| Copyright (c) 2010-2020, Mikko Koppanen <[email protected]> |
1212
| All rights reserved. |
1313
+-----------------------------------------------------------------------------------+
1414
| Redistribution and use in source and binary forms, with or without |

0 commit comments

Comments
 (0)