lestrrat-p5 / ZMQ

libzmq Perl binding
46 stars 31 forks source link

zmq_getsockopt for ZMQ_LAST_ENDPOINT should not return a string with a trailing null byte #48

Closed mjg17 closed 10 years ago

mjg17 commented 10 years ago

106_last_endpoint.t illustrates the problem. There's an extra \0 on the end of the string.

My patch to perl_libzmq3.xs strips the \0 if appropriate. This is a quick and pragmatic fix.

My PAUSE id is MJG.

Thanks for a really useful module! All the best Michael

mjg17 commented 10 years ago

A different approach would be to note that in fact only ZMQ_LAST_ENDPOINT really returns a string. ZMQ_SUBSCRIBE, ZMQ_UNSUBSCRIBE and ZMQ_IDENTITY take binary data.

So a new sockopt_type of binary could be introduced for them. get_sockopt_string() would then be renamed to get_sockopt_binary(), ditto for set_sockopt.

get_sockopt_string() could then be provided either in XS or perl, on top of get_sockopt_binary().