1# Node.js Binding for CZMQ 2 3This is a development kit. Note: this README is generated automatically 4by zproject from project.xml. Please DO NOT modify by hand except for test 5purposes. 6 7## Prerequisites 8 9### Node.js 10 11* You need Python (v2.7 recommended, v3.x not supported) 12* You need (I recommend) nvm and Node.js. 13* If your Linux has an existing 'node' command, `sudo apt-get remove node`. 14* In every terminal, or .bashrc: `nvm use v5.5.0` 15 16To install the necessary Node tools: 17 18``` 19sudo apt-get update 20sudo apt-get install build-essential libssl-dev 21curl https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash 22# close terminal, re-open 23nvm ls-remote 24nvm install v5.5.0 25npm install -g nan 26npm install -g node-ninja 27npm install -g prebuild 28npm install -g bindings 29``` 30 31To build: 32 33``` 34mkdir -p $HOME/temp 35cd $HOME/temp 36git clone https://github.com/zeromq/czmq 37cd czmq/bindings/nodejs 38# Clones dependencies, builds everything 39./build.sh 40``` 41 42## API 43 44This is a wrapping of the native C libczmq library. See binding.cc for the code. 45 46### The Zargs class - Platform independent command line argument parsing helpers 47 48There are two kind of elements provided by this class 49foo --named-parameter --parameter with_value positional arguments -a gain-parameter 50zargs keeps poision only for arguments, parameters are to be accessed like hash. 51 52It DOES: 53* provide easy to use CLASS compatible API for accessing argv 54* is platform independent 55* provide getopt_long style -- argument, which delimits parameters from arguments 56* makes parameters positon independent 57 58It does NOT 59* change argv 60* provide a "declarative" way to define command line interface 61 62In future it SHALL 63* hide several formats of command line to one (-Idir, --include=dir, 64 --include dir are the same from API pov) 65 66Constructor: 67 68``` 69var czmq = require ('bindings')('czmq') 70var my_zargs = new czmq.Zargs (Number, String) 71``` 72 73You *must* call the destructor on every Zargs instance: 74 75``` 76my_zargs.destroy () 77``` 78 79Methods: 80 81``` 82string my_zargs.progname () 83``` 84 85Return program name (argv[0]) 86 87``` 88size my_zargs.arguments () 89``` 90 91Return number of positional arguments 92 93``` 94string my_zargs.first () 95``` 96 97Return first positional argument or NULL 98 99``` 100string my_zargs.next () 101``` 102 103Return next positional argument or NULL 104 105``` 106string my_zargs.paramFirst () 107``` 108 109Return first named parameter value, or NULL if there are no named 110parameters, or value for which zargs_param_empty (arg) returns true. 111 112``` 113string my_zargs.paramNext () 114``` 115 116Return next named parameter value, or NULL if there are no named 117parameters, or value for which zargs_param_empty (arg) returns true. 118 119``` 120string my_zargs.paramName () 121``` 122 123Return current parameter name, or NULL if there are no named 124parameters. 125 126``` 127string my_zargs.paramLookup (String) 128``` 129 130Return value of named parameter, NULL if no given parameter has 131been specified, or special value for wich zargs_param_empty () 132returns true. 133 134``` 135string my_zargs.paramLookupx (String) 136``` 137 138Return value of named parameter(s), NULL if no given parameter has 139been specified, or special value for wich zargs_param_empty () 140returns true. 141 142``` 143boolean my_zargs.hasHelp () 144``` 145 146Returns true if there are --help -h arguments 147 148``` 149boolean my_zargs.paramEmpty (String) 150``` 151 152Returns true if parameter did not have a value 153 154``` 155nothing my_zargs.print () 156``` 157 158Print an instance of zargs. 159 160``` 161nothing my_zargs.test (Boolean) 162``` 163 164Self test of this class. 165 166### The Zarmour class - armoured text encoding and decoding 167 168Constructor: 169 170``` 171var czmq = require ('bindings')('czmq') 172var my_zarmour = new czmq.Zarmour () 173``` 174 175You *must* call the destructor on every Zarmour instance: 176 177``` 178my_zarmour.destroy () 179``` 180 181Methods: 182 183``` 184string my_zarmour.encode (String) 185``` 186 187Encode a stream of bytes into an armoured string. Returns the armoured 188string, or NULL if there was insufficient memory available to allocate 189a new string. 190 191``` 192zchunk my_zarmour.decode (String) 193``` 194 195Decode an armoured string into a chunk. The decoded output is 196null-terminated, so it may be treated as a string, if that's what 197it was prior to encoding. 198 199``` 200integer my_zarmour.mode () 201``` 202 203Get the mode property. 204 205``` 206string my_zarmour.modeStr () 207``` 208 209Get printable string for mode. 210 211``` 212nothing my_zarmour.setMode (Number) 213``` 214 215Set the mode property. 216 217``` 218boolean my_zarmour.pad () 219``` 220 221Return true if padding is turned on. 222 223``` 224nothing my_zarmour.setPad (Boolean) 225``` 226 227Turn padding on or off. Default is on. 228 229``` 230char my_zarmour.padChar () 231``` 232 233Get the padding character. 234 235``` 236nothing my_zarmour.setPadChar (String) 237``` 238 239Set the padding character. 240 241``` 242boolean my_zarmour.lineBreaks () 243``` 244 245Return if splitting output into lines is turned on. Default is off. 246 247``` 248nothing my_zarmour.setLineBreaks (Boolean) 249``` 250 251Turn splitting output into lines on or off. 252 253``` 254size my_zarmour.lineLength () 255``` 256 257Get the line length used for splitting lines. 258 259``` 260nothing my_zarmour.setLineLength () 261``` 262 263Set the line length used for splitting lines. 264 265``` 266nothing my_zarmour.print () 267``` 268 269Print properties of object 270 271``` 272nothing my_zarmour.test (Boolean) 273``` 274 275Self test of this class. 276 277### The Zcert class - work with CURVE security certificates 278 279Constructor: 280 281``` 282var czmq = require ('bindings')('czmq') 283var my_zcert = new czmq.Zcert () 284``` 285 286You *must* call the destructor on every Zcert instance: 287 288``` 289my_zcert.destroy () 290``` 291 292Methods: 293 294``` 295buffer my_zcert.publicKey () 296``` 297 298Return public part of key pair as 32-byte binary string 299 300``` 301buffer my_zcert.secretKey () 302``` 303 304Return secret part of key pair as 32-byte binary string 305 306``` 307string my_zcert.publicTxt () 308``` 309 310Return public part of key pair as Z85 armored string 311 312``` 313string my_zcert.secretTxt () 314``` 315 316Return secret part of key pair as Z85 armored string 317 318``` 319nothing my_zcert.setMeta (String, String) 320``` 321 322Set certificate metadata from formatted string. 323 324``` 325nothing my_zcert.unsetMeta (String) 326``` 327 328Unset certificate metadata. 329 330``` 331string my_zcert.meta (String) 332``` 333 334Get metadata value from certificate; if the metadata value doesn't 335exist, returns NULL. 336 337``` 338zlist my_zcert.metaKeys () 339``` 340 341Get list of metadata fields from certificate. Caller is responsible for 342destroying list. Caller should not modify the values of list items. 343 344``` 345integer my_zcert.save (String) 346``` 347 348Save full certificate (public + secret) to file for persistent storage 349This creates one public file and one secret file (filename + "_secret"). 350 351``` 352integer my_zcert.savePublic (String) 353``` 354 355Save public certificate only to file for persistent storage 356 357``` 358integer my_zcert.saveSecret (String) 359``` 360 361Save secret certificate only to file for persistent storage 362 363``` 364nothing my_zcert.apply (Zsock) 365``` 366 367Apply certificate to socket, i.e. use for CURVE security on socket. 368If certificate was loaded from public file, the secret key will be 369undefined, and this certificate will not work successfully. 370 371``` 372zcert my_zcert.dup () 373``` 374 375Return copy of certificate; if certificate is NULL or we exhausted 376heap memory, returns NULL. 377 378``` 379boolean my_zcert.eq (Zcert) 380``` 381 382Return true if two certificates have the same keys 383 384``` 385nothing my_zcert.print () 386``` 387 388Print certificate contents to stdout 389 390``` 391nothing my_zcert.test (Boolean) 392``` 393 394Self test of this class 395 396### The Zcertstore class - work with CURVE security certificate stores 397 398Constructor: 399 400``` 401var czmq = require ('bindings')('czmq') 402var my_zcertstore = new czmq.Zcertstore (String) 403``` 404 405You *must* call the destructor on every Zcertstore instance: 406 407``` 408my_zcertstore.destroy () 409``` 410 411Methods: 412 413``` 414zcert my_zcertstore.lookup (String) 415``` 416 417Look up certificate by public key, returns zcert_t object if found, 418else returns NULL. The public key is provided in Z85 text format. 419 420``` 421nothing my_zcertstore.insert (Zcert) 422``` 423 424Insert certificate into certificate store in memory. Note that this 425does not save the certificate to disk. To do that, use zcert_save() 426directly on the certificate. Takes ownership of zcert_t object. 427 428``` 429nothing my_zcertstore.empty () 430``` 431 432Empty certificate hashtable. This wrapper exists to be friendly to bindings, 433which don't usually have access to struct internals. 434 435``` 436nothing my_zcertstore.print () 437``` 438 439Print list of certificates in store to logging facility 440 441``` 442zlistx my_zcertstore.certs () 443``` 444 445Return a list of all the certificates in the store. 446The caller takes ownership of the zlistx_t object and is responsible 447for destroying it. The caller does not take ownership of the zcert_t 448objects. 449 450``` 451nothing my_zcertstore.test (Boolean) 452``` 453 454Self test of this class 455 456### The Zchunk class - work with memory chunks 457 458Constructor: 459 460``` 461var czmq = require ('bindings')('czmq') 462var my_zchunk = new czmq.Zchunk (String) 463``` 464 465You *must* call the destructor on every Zchunk instance: 466 467``` 468my_zchunk.destroy () 469``` 470 471Methods: 472 473``` 474nothing my_zchunk.resize () 475``` 476 477Resizes chunk max_size as requested; chunk_cur size is set to zero 478 479``` 480size my_zchunk.size () 481``` 482 483Return chunk cur size 484 485``` 486size my_zchunk.maxSize () 487``` 488 489Return chunk max size 490 491``` 492buffer my_zchunk.data () 493``` 494 495Return chunk data 496 497``` 498size my_zchunk.set (String) 499``` 500 501Set chunk data from user-supplied data; truncate if too large. Data may 502be null. Returns actual size of chunk 503 504``` 505size my_zchunk.append (String) 506``` 507 508Append user-supplied data to chunk, return resulting chunk size. If the 509data would exceeded the available space, it is truncated. If you want to 510grow the chunk to accommodate new data, use the zchunk_extend method. 511 512``` 513size my_zchunk.extend (String) 514``` 515 516Append user-supplied data to chunk, return resulting chunk size. If the 517data would exceeded the available space, the chunk grows in size. 518 519``` 520size my_zchunk.consume (Zchunk) 521``` 522 523Copy as much data from 'source' into the chunk as possible; returns the 524new size of chunk. If all data from 'source' is used, returns exhausted 525on the source chunk. Source can be consumed as many times as needed until 526it is exhausted. If source was already exhausted, does not change chunk. 527 528``` 529boolean my_zchunk.exhausted () 530``` 531 532Returns true if the chunk was exhausted by consume methods, or if the 533chunk has a size of zero. 534 535``` 536zchunk my_zchunk.slurp (String) 537``` 538 539Try to slurp an entire file into a chunk. Will read up to maxsize of 540the file. If maxsize is 0, will attempt to read the entire file and 541fail with an assertion if that cannot fit into memory. Returns a new 542chunk containing the file data, or NULL if the file could not be read. 543 544``` 545zchunk my_zchunk.dup () 546``` 547 548Create copy of chunk, as new chunk object. Returns a fresh zchunk_t 549object, or null if there was not enough heap memory. If chunk is null, 550returns null. 551 552``` 553string my_zchunk.strhex () 554``` 555 556Return chunk data encoded as printable hex string. Caller must free 557string when finished with it. 558 559``` 560string my_zchunk.strdup () 561``` 562 563Return chunk data copied into freshly allocated string 564Caller must free string when finished with it. 565 566``` 567boolean my_zchunk.streq (String) 568``` 569 570Return TRUE if chunk body is equal to string, excluding terminator 571 572``` 573zframe my_zchunk.pack () 574``` 575 576Transform zchunk into a zframe that can be sent in a message. 577 578``` 579zchunk my_zchunk.unpack (Zframe) 580``` 581 582Transform a zframe into a zchunk. 583 584``` 585string my_zchunk.digest () 586``` 587 588Calculate SHA1 digest for chunk, using zdigest class. 589 590``` 591nothing my_zchunk.print () 592``` 593 594Dump message to stderr, for debugging and tracing. 595See zchunk_fprint for details 596 597``` 598nothing my_zchunk.test (Boolean) 599``` 600 601Self test of this class. 602 603### The Zclock class - millisecond clocks and delays 604 605Constructor: 606 607``` 608var czmq = require ('bindings')('czmq') 609var my_zclock = new czmq.Zclock () 610``` 611 612Methods: 613 614``` 615nothing my_zclock.sleep (Number) 616``` 617 618Sleep for a number of milliseconds 619 620``` 621msecs my_zclock.time () 622``` 623 624Return current system clock as milliseconds. Note that this clock can 625jump backwards (if the system clock is changed) so is unsafe to use for 626timers and time offsets. Use zclock_mono for that instead. 627 628``` 629msecs my_zclock.mono () 630``` 631 632Return current monotonic clock in milliseconds. Use this when you compute 633time offsets. The monotonic clock is not affected by system changes and 634so will never be reset backwards, unlike a system clock. 635 636``` 637msecs my_zclock.usecs () 638``` 639 640Return current monotonic clock in microseconds. Use this when you compute 641time offsets. The monotonic clock is not affected by system changes and 642so will never be reset backwards, unlike a system clock. 643 644``` 645string my_zclock.timestr () 646``` 647 648Return formatted date/time as fresh string. Free using zstr_free(). 649 650``` 651nothing my_zclock.test (Boolean) 652``` 653 654Self test of this class. 655 656### The Zconfig class - work with config files written in rfc.zeromq.org/spec:4/ZPL. 657 658Constructor: 659 660``` 661var czmq = require ('bindings')('czmq') 662var my_zconfig = new czmq.Zconfig (String, Zconfig) 663``` 664 665You *must* call the destructor on every Zconfig instance: 666 667``` 668my_zconfig.destroy () 669``` 670 671Methods: 672 673``` 674string my_zconfig.name () 675``` 676 677Return name of config item 678 679``` 680string my_zconfig.value () 681``` 682 683Return value of config item 684 685``` 686nothing my_zconfig.put (String, String) 687``` 688 689Insert or update configuration key with value 690 691``` 692nothing my_zconfig.putf (String, String) 693``` 694 695Equivalent to zconfig_put, accepting a format specifier and variable 696argument list, instead of a single string value. 697 698``` 699string my_zconfig.get (String, String) 700``` 701 702Get value for config item into a string value; leading slash is optional 703and ignored. 704 705``` 706nothing my_zconfig.setName (String) 707``` 708 709Set config item name, name may be NULL 710 711``` 712nothing my_zconfig.setValue (String) 713``` 714 715Set new value for config item. The new value may be a string, a printf 716format, or NULL. Note that if string may possibly contain '%', or if it 717comes from an insecure source, you must use '%s' as the format, followed 718by the string. 719 720``` 721zconfig my_zconfig.child () 722``` 723 724Find our first child, if any 725 726``` 727zconfig my_zconfig.next () 728``` 729 730Find our first sibling, if any 731 732``` 733zconfig my_zconfig.locate (String) 734``` 735 736Find a config item along a path; leading slash is optional and ignored. 737 738``` 739zconfig my_zconfig.atDepth (Number) 740``` 741 742Locate the last config item at a specified depth 743 744``` 745nothing my_zconfig.setComment (String) 746``` 747 748Add comment to config item before saving to disk. You can add as many 749comment lines as you like. If you use a null format, all comments are 750deleted. 751 752``` 753zlist my_zconfig.comments () 754``` 755 756Return comments of config item, as zlist. 757 758``` 759integer my_zconfig.save (String) 760``` 761 762Save a config tree to a specified ZPL text file, where a filename 763"-" means dump to standard output. 764 765``` 766integer my_zconfig.savef (String) 767``` 768 769Equivalent to zconfig_save, taking a format string instead of a fixed 770filename. 771 772``` 773string my_zconfig.filename () 774``` 775 776Report filename used during zconfig_load, or NULL if none 777 778``` 779integer my_zconfig.reload (Zconfig) 780``` 781 782Reload config tree from same file that it was previously loaded from. 783Returns 0 if OK, -1 if there was an error (and then does not change 784existing data). 785 786``` 787zconfig my_zconfig.chunkLoad (Zchunk) 788``` 789 790Load a config tree from a memory chunk 791 792``` 793zchunk my_zconfig.chunkSave () 794``` 795 796Save a config tree to a new memory chunk 797 798``` 799zconfig my_zconfig.strLoad (String) 800``` 801 802Load a config tree from a null-terminated string 803 804``` 805string my_zconfig.strSave () 806``` 807 808Save a config tree to a new null terminated string 809 810``` 811boolean my_zconfig.hasChanged () 812``` 813 814Return true if a configuration tree was loaded from a file and that 815file has changed in since the tree was loaded. 816 817``` 818nothing my_zconfig.removeSubtree () 819``` 820 821Destroy subtree (all children) 822 823``` 824nothing my_zconfig.remove (Zconfig) 825``` 826 827Destroy node and subtree (all children) 828 829``` 830nothing my_zconfig.print () 831``` 832 833Print properties of object 834 835``` 836nothing my_zconfig.test (Boolean) 837``` 838 839Self test of this class 840 841### The Zdigest class - provides hashing functions (SHA-1 at present) 842 843Constructor: 844 845``` 846var czmq = require ('bindings')('czmq') 847var my_zdigest = new czmq.Zdigest () 848``` 849 850You *must* call the destructor on every Zdigest instance: 851 852``` 853my_zdigest.destroy () 854``` 855 856Methods: 857 858``` 859nothing my_zdigest.update (String) 860``` 861 862Add buffer into digest calculation 863 864``` 865buffer my_zdigest.data () 866``` 867 868Return final digest hash data. If built without crypto support, 869returns NULL. 870 871``` 872size my_zdigest.size () 873``` 874 875Return final digest hash size 876 877``` 878string my_zdigest.string () 879``` 880 881Return digest as printable hex string; caller should not modify nor 882free this string. After calling this, you may not use zdigest_update() 883on the same digest. If built without crypto support, returns NULL. 884 885``` 886nothing my_zdigest.test (Boolean) 887``` 888 889Self test of this class. 890 891### The Zdir class - work with file-system directories 892 893Constructor: 894 895``` 896var czmq = require ('bindings')('czmq') 897var my_zdir = new czmq.Zdir (String, String) 898``` 899 900You *must* call the destructor on every Zdir instance: 901 902``` 903my_zdir.destroy () 904``` 905 906Methods: 907 908``` 909string my_zdir.path () 910``` 911 912Return directory path 913 914``` 915time my_zdir.modified () 916``` 917 918Return last modification time for directory. 919 920``` 921file_size my_zdir.cursize () 922``` 923 924Return total hierarchy size, in bytes of data contained in all files 925in the directory tree. 926 927``` 928size my_zdir.count () 929``` 930 931Return directory count 932 933``` 934zlist my_zdir.list () 935``` 936 937Returns a sorted list of zfile objects; Each entry in the list is a pointer 938to a zfile_t item already allocated in the zdir tree. Do not destroy the 939original zdir tree until you are done with this list. 940 941``` 942nothing my_zdir.remove (Boolean) 943``` 944 945Remove directory, optionally including all files that it contains, at 946all levels. If force is false, will only remove the directory if empty. 947If force is true, will remove all files and all subdirectories. 948 949``` 950zlist my_zdir.diff (Zdir, Zdir, String) 951``` 952 953Calculate differences between two versions of a directory tree. 954Returns a list of zdir_patch_t patches. Either older or newer may 955be null, indicating the directory is empty/absent. If alias is set, 956generates virtual filename (minus path, plus alias). 957 958``` 959zlist my_zdir.resync (String) 960``` 961 962Return full contents of directory as a zdir_patch list. 963 964``` 965zhash my_zdir.cache () 966``` 967 968Load directory cache; returns a hash table containing the SHA-1 digests 969of every file in the tree. The cache is saved between runs in .cache. 970 971``` 972nothing my_zdir.print (Number) 973``` 974 975Print contents of directory to stdout 976 977``` 978nothing my_zdir.test (Boolean) 979``` 980 981Self test of this class. 982 983### The ZdirPatch class - work with directory patches 984 985Constructor: 986 987``` 988var czmq = require ('bindings')('czmq') 989var my_zdir_patch = new czmq.ZdirPatch (String, Zfile, Number, String) 990``` 991 992You *must* call the destructor on every ZdirPatch instance: 993 994``` 995my_zdir_patch.destroy () 996``` 997 998Methods: 999 1000``` 1001zdir_patch my_zdir_patch.dup () 1002``` 1003 1004Create copy of a patch. If the patch is null, or memory was exhausted, 1005returns null. 1006 1007``` 1008string my_zdir_patch.path () 1009``` 1010 1011Return patch file directory path 1012 1013``` 1014zfile my_zdir_patch.file () 1015``` 1016 1017Return patch file item 1018 1019``` 1020integer my_zdir_patch.op () 1021``` 1022 1023Return operation 1024 1025``` 1026string my_zdir_patch.vpath () 1027``` 1028 1029Return patch virtual file path 1030 1031``` 1032nothing my_zdir_patch.digestSet () 1033``` 1034 1035Calculate hash digest for file (create only) 1036 1037``` 1038string my_zdir_patch.digest () 1039``` 1040 1041Return hash digest for patch file 1042 1043``` 1044nothing my_zdir_patch.test (Boolean) 1045``` 1046 1047Self test of this class. 1048 1049### The Zfile class - helper functions for working with files. 1050 1051Constructor: 1052 1053``` 1054var czmq = require ('bindings')('czmq') 1055var my_zfile = new czmq.Zfile (String, String) 1056``` 1057 1058You *must* call the destructor on every Zfile instance: 1059 1060``` 1061my_zfile.destroy () 1062``` 1063 1064Methods: 1065 1066``` 1067zfile my_zfile.dup () 1068``` 1069 1070Duplicate a file item, returns a newly constructed item. If the file 1071is null, or memory was exhausted, returns null. 1072 1073``` 1074string my_zfile.filename (String) 1075``` 1076 1077Return file name, remove path if provided 1078 1079``` 1080nothing my_zfile.restat () 1081``` 1082 1083Refresh file properties from disk; this is not done automatically 1084on access methods, otherwise it is not possible to compare directory 1085snapshots. 1086 1087``` 1088time my_zfile.modified () 1089``` 1090 1091Return when the file was last modified. If you want this to reflect the 1092current situation, call zfile_restat before checking this property. 1093 1094``` 1095file_size my_zfile.cursize () 1096``` 1097 1098Return the last-known size of the file. If you want this to reflect the 1099current situation, call zfile_restat before checking this property. 1100 1101``` 1102boolean my_zfile.isDirectory () 1103``` 1104 1105Return true if the file is a directory. If you want this to reflect 1106any external changes, call zfile_restat before checking this property. 1107 1108``` 1109boolean my_zfile.isRegular () 1110``` 1111 1112Return true if the file is a regular file. If you want this to reflect 1113any external changes, call zfile_restat before checking this property. 1114 1115``` 1116boolean my_zfile.isReadable () 1117``` 1118 1119Return true if the file is readable by this process. If you want this to 1120reflect any external changes, call zfile_restat before checking this 1121property. 1122 1123``` 1124boolean my_zfile.isWriteable () 1125``` 1126 1127Return true if the file is writeable by this process. If you want this 1128to reflect any external changes, call zfile_restat before checking this 1129property. 1130 1131``` 1132boolean my_zfile.isStable () 1133``` 1134 1135Check if file has stopped changing and can be safely processed. 1136Updates the file statistics from disk at every call. 1137 1138``` 1139boolean my_zfile.hasChanged () 1140``` 1141 1142Return true if the file was changed on disk since the zfile_t object 1143was created, or the last zfile_restat() call made on it. 1144 1145``` 1146nothing my_zfile.remove () 1147``` 1148 1149Remove the file from disk 1150 1151``` 1152integer my_zfile.input () 1153``` 1154 1155Open file for reading 1156Returns 0 if OK, -1 if not found or not accessible 1157 1158``` 1159integer my_zfile.output () 1160``` 1161 1162Open file for writing, creating directory if needed 1163File is created if necessary; chunks can be written to file at any 1164location. Returns 0 if OK, -1 if error. 1165 1166``` 1167zchunk my_zfile.read (, Number) 1168``` 1169 1170Read chunk from file at specified position. If this was the last chunk, 1171sets the eof property. Returns a null chunk in case of error. 1172 1173``` 1174boolean my_zfile.eof () 1175``` 1176 1177Returns true if zfile_read() just read the last chunk in the file. 1178 1179``` 1180integer my_zfile.write (Zchunk, Number) 1181``` 1182 1183Write chunk to file at specified position 1184Return 0 if OK, else -1 1185 1186``` 1187string my_zfile.readln () 1188``` 1189 1190Read next line of text from file. Returns a pointer to the text line, 1191or NULL if there was nothing more to read from the file. 1192 1193``` 1194nothing my_zfile.close () 1195``` 1196 1197Close file, if open 1198 1199``` 1200string my_zfile.digest () 1201``` 1202 1203Calculate SHA1 digest for file, using zdigest class. 1204 1205``` 1206nothing my_zfile.test (Boolean) 1207``` 1208 1209Self test of this class. 1210 1211### The Zframe class - working with single message frames 1212 1213Constructor: 1214 1215``` 1216var czmq = require ('bindings')('czmq') 1217var my_zframe = new czmq.Zframe (String) 1218``` 1219 1220You *must* call the destructor on every Zframe instance: 1221 1222``` 1223my_zframe.destroy () 1224``` 1225 1226Methods: 1227 1228``` 1229integer my_zframe.send (Zframe, Zsock, Number) 1230``` 1231 1232Send a frame to a socket, destroy frame after sending. 1233Return -1 on error, 0 on success. 1234 1235``` 1236size my_zframe.size () 1237``` 1238 1239Return number of bytes in frame data 1240 1241``` 1242buffer my_zframe.data () 1243``` 1244 1245Return address of frame data 1246 1247``` 1248string my_zframe.meta (String) 1249``` 1250 1251Return meta data property for frame 1252The caller shall not modify or free the returned value, which shall be 1253owned by the message. 1254 1255``` 1256zframe my_zframe.dup () 1257``` 1258 1259Create a new frame that duplicates an existing frame. If frame is null, 1260or memory was exhausted, returns null. 1261 1262``` 1263string my_zframe.strhex () 1264``` 1265 1266Return frame data encoded as printable hex string, useful for 0MQ UUIDs. 1267Caller must free string when finished with it. 1268 1269``` 1270string my_zframe.strdup () 1271``` 1272 1273Return frame data copied into freshly allocated string 1274Caller must free string when finished with it. 1275 1276``` 1277boolean my_zframe.streq (String) 1278``` 1279 1280Return TRUE if frame body is equal to string, excluding terminator 1281 1282``` 1283integer my_zframe.more () 1284``` 1285 1286Return frame MORE indicator (1 or 0), set when reading frame from socket 1287or by the zframe_set_more() method 1288 1289``` 1290nothing my_zframe.setMore (Number) 1291``` 1292 1293Set frame MORE indicator (1 or 0). Note this is NOT used when sending 1294frame to socket, you have to specify flag explicitly. 1295 1296``` 1297number my_zframe.routingId () 1298``` 1299 1300Return frame routing ID, if the frame came from a ZMQ_SERVER socket. 1301Else returns zero. 1302 1303``` 1304nothing my_zframe.setRoutingId (Number) 1305``` 1306 1307Set routing ID on frame. This is used if/when the frame is sent to a 1308ZMQ_SERVER socket. 1309 1310``` 1311string my_zframe.group () 1312``` 1313 1314Return frame group of radio-dish pattern. 1315 1316``` 1317integer my_zframe.setGroup (String) 1318``` 1319 1320Set group on frame. This is used if/when the frame is sent to a 1321ZMQ_RADIO socket. 1322Return -1 on error, 0 on success. 1323 1324``` 1325boolean my_zframe.eq (Zframe) 1326``` 1327 1328Return TRUE if two frames have identical size and data 1329If either frame is NULL, equality is always false. 1330 1331``` 1332nothing my_zframe.reset (String) 1333``` 1334 1335Set new contents for frame 1336 1337``` 1338nothing my_zframe.print (String) 1339``` 1340 1341Send message to zsys log sink (may be stdout, or system facility as 1342configured by zsys_set_logstream). Prefix shows before frame, if not null. 1343 1344``` 1345nothing my_zframe.test (Boolean) 1346``` 1347 1348Self test of this class. 1349 1350### The Zhash class - generic type-free hash container (simple) 1351 1352Constructor: 1353 1354``` 1355var czmq = require ('bindings')('czmq') 1356var my_zhash = new czmq.Zhash () 1357``` 1358 1359You *must* call the destructor on every Zhash instance: 1360 1361``` 1362my_zhash.destroy () 1363``` 1364 1365Methods: 1366 1367``` 1368nothing my_zhash.delete (String) 1369``` 1370 1371Remove an item specified by key from the hash table. If there was no such 1372item, this function does nothing. 1373 1374``` 1375integer my_zhash.rename (String, String) 1376``` 1377 1378Reindexes an item from an old key to a new key. If there was no such 1379item, does nothing. Returns 0 if successful, else -1. 1380 1381``` 1382size my_zhash.size () 1383``` 1384 1385Return the number of keys/items in the hash table 1386 1387``` 1388zhash my_zhash.dup () 1389``` 1390 1391Make copy of hash table; if supplied table is null, returns null. 1392Does not copy items themselves. Rebuilds new table so may be slow on 1393very large tables. NOTE: only works with item values that are strings 1394since there's no other way to know how to duplicate the item value. 1395 1396``` 1397zlist my_zhash.keys () 1398``` 1399 1400Return keys for items in table 1401 1402``` 1403string my_zhash.cursor () 1404``` 1405 1406After a successful first/next method, returns the key for the item that 1407was returned. This is a constant string that you may not modify or 1408deallocate, and which lasts as long as the item in the hash. After an 1409unsuccessful first/next, returns NULL. 1410 1411``` 1412nothing my_zhash.comment (String) 1413``` 1414 1415Add a comment to hash table before saving to disk. You can add as many 1416comment lines as you like. These comment lines are discarded when loading 1417the file. If you use a null format, all comments are deleted. 1418 1419``` 1420zframe my_zhash.pack () 1421``` 1422 1423Serialize hash table to a binary frame that can be sent in a message. 1424The packed format is compatible with the 'dictionary' type defined in 1425http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: 1426 1427 ; A list of name/value pairs 1428 dictionary = dict-count *( dict-name dict-value ) 1429 dict-count = number-4 1430 dict-value = longstr 1431 dict-name = string 1432 1433 ; Strings are always length + text contents 1434 longstr = number-4 *VCHAR 1435 string = number-1 *VCHAR 1436 1437 ; Numbers are unsigned integers in network byte order 1438 number-1 = 1OCTET 1439 number-4 = 4OCTET 1440 1441Comments are not included in the packed data. Item values MUST be 1442strings. 1443 1444``` 1445integer my_zhash.save (String) 1446``` 1447 1448Save hash table to a text file in name=value format. Hash values must be 1449printable strings; keys may not contain '=' character. Returns 0 if OK, 1450else -1 if a file error occurred. 1451 1452``` 1453integer my_zhash.load (String) 1454``` 1455 1456Load hash table from a text file in name=value format; hash table must 1457already exist. Hash values must printable strings; keys may not contain 1458'=' character. Returns 0 if OK, else -1 if a file was not readable. 1459 1460``` 1461integer my_zhash.refresh () 1462``` 1463 1464When a hash table was loaded from a file by zhash_load, this method will 1465reload the file if it has been modified since, and is "stable", i.e. not 1466still changing. Returns 0 if OK, -1 if there was an error reloading the 1467file. 1468 1469``` 1470nothing my_zhash.autofree () 1471``` 1472 1473Set hash for automatic value destruction. Note that this assumes that 1474values are NULL-terminated strings. Do not use with different types. 1475 1476``` 1477nothing my_zhash.test (Boolean) 1478``` 1479 1480Self test of this class. 1481 1482### The Zhashx class - extended generic type-free hash container 1483 1484Constructor: 1485 1486``` 1487var czmq = require ('bindings')('czmq') 1488var my_zhashx = new czmq.Zhashx () 1489``` 1490 1491You *must* call the destructor on every Zhashx instance: 1492 1493``` 1494my_zhashx.destroy () 1495``` 1496 1497Methods: 1498 1499``` 1500nothing my_zhashx.purge () 1501``` 1502 1503Delete all items from the hash table. If the key destructor is 1504set, calls it on every key. If the item destructor is set, calls 1505it on every item. 1506 1507``` 1508size my_zhashx.size () 1509``` 1510 1511Return the number of keys/items in the hash table 1512 1513``` 1514zlistx my_zhashx.keys () 1515``` 1516 1517Return a zlistx_t containing the keys for the items in the 1518table. Uses the key_duplicator to duplicate all keys and sets the 1519key_destructor as destructor for the list. 1520 1521``` 1522zlistx my_zhashx.values () 1523``` 1524 1525Return a zlistx_t containing the values for the items in the 1526table. Uses the duplicator to duplicate all items and sets the 1527destructor as destructor for the list. 1528 1529``` 1530nothing my_zhashx.comment (String) 1531``` 1532 1533Add a comment to hash table before saving to disk. You can add as many 1534comment lines as you like. These comment lines are discarded when loading 1535the file. If you use a null format, all comments are deleted. 1536 1537``` 1538integer my_zhashx.save (String) 1539``` 1540 1541Save hash table to a text file in name=value format. Hash values must be 1542printable strings; keys may not contain '=' character. Returns 0 if OK, 1543else -1 if a file error occurred. 1544 1545``` 1546integer my_zhashx.load (String) 1547``` 1548 1549Load hash table from a text file in name=value format; hash table must 1550already exist. Hash values must printable strings; keys may not contain 1551'=' character. Returns 0 if OK, else -1 if a file was not readable. 1552 1553``` 1554integer my_zhashx.refresh () 1555``` 1556 1557When a hash table was loaded from a file by zhashx_load, this method will 1558reload the file if it has been modified since, and is "stable", i.e. not 1559still changing. Returns 0 if OK, -1 if there was an error reloading the 1560file. 1561 1562``` 1563zframe my_zhashx.pack () 1564``` 1565 1566Serialize hash table to a binary frame that can be sent in a message. 1567The packed format is compatible with the 'dictionary' type defined in 1568http://rfc.zeromq.org/spec:35/FILEMQ, and implemented by zproto: 1569 1570 ; A list of name/value pairs 1571 dictionary = dict-count *( dict-name dict-value ) 1572 dict-count = number-4 1573 dict-value = longstr 1574 dict-name = string 1575 1576 ; Strings are always length + text contents 1577 longstr = number-4 *VCHAR 1578 string = number-1 *VCHAR 1579 1580 ; Numbers are unsigned integers in network byte order 1581 number-1 = 1OCTET 1582 number-4 = 4OCTET 1583 1584Comments are not included in the packed data. Item values MUST be 1585strings. 1586 1587``` 1588zhashx my_zhashx.dup () 1589``` 1590 1591Make a copy of the list; items are duplicated if you set a duplicator 1592for the list, otherwise not. Copying a null reference returns a null 1593reference. Note that this method's behavior changed slightly for CZMQ 1594v3.x, as it does not set nor respect autofree. It does however let you 1595duplicate any hash table safely. The old behavior is in zhashx_dup_v2. 1596 1597``` 1598zhashx my_zhashx.dupV2 () 1599``` 1600 1601Make copy of hash table; if supplied table is null, returns null. 1602Does not copy items themselves. Rebuilds new table so may be slow on 1603very large tables. NOTE: only works with item values that are strings 1604since there's no other way to know how to duplicate the item value. 1605 1606``` 1607nothing my_zhashx.test (Boolean) 1608``` 1609 1610Self test of this class. 1611 1612### The Ziflist class - List of network interfaces available on system 1613 1614Constructor: 1615 1616``` 1617var czmq = require ('bindings')('czmq') 1618var my_ziflist = new czmq.Ziflist () 1619``` 1620 1621You *must* call the destructor on every Ziflist instance: 1622 1623``` 1624my_ziflist.destroy () 1625``` 1626 1627Methods: 1628 1629``` 1630nothing my_ziflist.reload () 1631``` 1632 1633Reload network interfaces from system 1634 1635``` 1636size my_ziflist.size () 1637``` 1638 1639Return the number of network interfaces on system 1640 1641``` 1642string my_ziflist.first () 1643``` 1644 1645Get first network interface, return NULL if there are none 1646 1647``` 1648string my_ziflist.next () 1649``` 1650 1651Get next network interface, return NULL if we hit the last one 1652 1653``` 1654string my_ziflist.address () 1655``` 1656 1657Return the current interface IP address as a printable string 1658 1659``` 1660string my_ziflist.broadcast () 1661``` 1662 1663Return the current interface broadcast address as a printable string 1664 1665``` 1666string my_ziflist.netmask () 1667``` 1668 1669Return the current interface network mask as a printable string 1670 1671``` 1672nothing my_ziflist.print () 1673``` 1674 1675Return the list of interfaces. 1676 1677``` 1678ziflist my_ziflist.newIpv6 () 1679``` 1680 1681Get a list of network interfaces currently defined on the system 1682Includes IPv6 interfaces 1683 1684``` 1685nothing my_ziflist.reloadIpv6 () 1686``` 1687 1688Reload network interfaces from system, including IPv6 1689 1690``` 1691boolean my_ziflist.isIpv6 () 1692``` 1693 1694Return true if the current interface uses IPv6 1695 1696``` 1697nothing my_ziflist.test (Boolean) 1698``` 1699 1700Self test of this class. 1701 1702### The Zlist class - simple generic list container 1703 1704Constructor: 1705 1706``` 1707var czmq = require ('bindings')('czmq') 1708var my_zlist = new czmq.Zlist () 1709``` 1710 1711You *must* call the destructor on every Zlist instance: 1712 1713``` 1714my_zlist.destroy () 1715``` 1716 1717Methods: 1718 1719``` 1720zlist my_zlist.dup () 1721``` 1722 1723Make a copy of list. If the list has autofree set, the copied list will 1724duplicate all items, which must be strings. Otherwise, the list will hold 1725pointers back to the items in the original list. If list is null, returns 1726NULL. 1727 1728``` 1729nothing my_zlist.purge () 1730``` 1731 1732Purge all items from list 1733 1734``` 1735size my_zlist.size () 1736``` 1737 1738Return number of items in the list 1739 1740``` 1741nothing my_zlist.autofree () 1742``` 1743 1744Set list for automatic item destruction; item values MUST be strings. 1745By default a list item refers to a value held elsewhere. When you set 1746this, each time you append or push a list item, zlist will take a copy 1747of the string value. Then, when you destroy the list, it will free all 1748item values automatically. If you use any other technique to allocate 1749list values, you must free them explicitly before destroying the list. 1750The usual technique is to pop list items and destroy them, until the 1751list is empty. 1752 1753``` 1754nothing my_zlist.test (Boolean) 1755``` 1756 1757Self test of this class. 1758 1759### The Zlistx class - extended generic list container 1760 1761Constructor: 1762 1763``` 1764var czmq = require ('bindings')('czmq') 1765var my_zlistx = new czmq.Zlistx () 1766``` 1767 1768You *must* call the destructor on every Zlistx instance: 1769 1770``` 1771my_zlistx.destroy () 1772``` 1773 1774Methods: 1775 1776``` 1777size my_zlistx.size () 1778``` 1779 1780Return the number of items in the list 1781 1782``` 1783nothing my_zlistx.purge () 1784``` 1785 1786Remove all items from the list, and destroy them if the item destructor 1787is set. 1788 1789``` 1790nothing my_zlistx.sort () 1791``` 1792 1793Sort the list. If an item comparator was set, calls that to compare 1794items, otherwise compares on item value. The sort is not stable, so may 1795reorder equal items. 1796 1797``` 1798zlistx my_zlistx.dup () 1799``` 1800 1801Make a copy of the list; items are duplicated if you set a duplicator 1802for the list, otherwise not. Copying a null reference returns a null 1803reference. 1804 1805``` 1806nothing my_zlistx.test (Boolean) 1807``` 1808 1809Self test of this class. 1810 1811### The Zloop class - event-driven reactor 1812 1813Constructor: 1814 1815``` 1816var czmq = require ('bindings')('czmq') 1817var my_zloop = new czmq.Zloop () 1818``` 1819 1820You *must* call the destructor on every Zloop instance: 1821 1822``` 1823my_zloop.destroy () 1824``` 1825 1826Methods: 1827 1828``` 1829nothing my_zloop.readerEnd (Zsock) 1830``` 1831 1832Cancel a socket reader from the reactor. If multiple readers exist for 1833same socket, cancels ALL of them. 1834 1835``` 1836nothing my_zloop.readerSetTolerant (Zsock) 1837``` 1838 1839Configure a registered reader to ignore errors. If you do not set this, 1840then readers that have errors are removed from the reactor silently. 1841 1842``` 1843integer my_zloop.timerEnd (Number) 1844``` 1845 1846Cancel a specific timer identified by a specific timer_id (as returned by 1847zloop_timer). 1848 1849``` 1850nothing my_zloop.setTicketDelay () 1851``` 1852 1853Set the ticket delay, which applies to all tickets. If you lower the 1854delay and there are already tickets created, the results are undefined. 1855 1856``` 1857nothing my_zloop.setMaxTimers () 1858``` 1859 1860Set hard limit on number of timers allowed. Setting more than a small 1861number of timers (10-100) can have a dramatic impact on the performance 1862of the reactor. For high-volume cases, use ticket timers. If the hard 1863limit is reached, the reactor stops creating new timers and logs an 1864error. 1865 1866``` 1867nothing my_zloop.setVerbose (Boolean) 1868``` 1869 1870Set verbose tracing of reactor on/off. The default verbose setting is 1871off (false). 1872 1873``` 1874nothing my_zloop.setNonstop (Boolean) 1875``` 1876 1877By default the reactor stops if the process receives a SIGINT or SIGTERM 1878signal. This makes it impossible to shut-down message based architectures 1879like zactors. This method lets you switch off break handling. The default 1880nonstop setting is off (false). 1881 1882``` 1883integer my_zloop.start () 1884``` 1885 1886Start the reactor. Takes control of the thread and returns when the 0MQ 1887context is terminated or the process is interrupted, or any event handler 1888returns -1. Event handlers may register new sockets and timers, and 1889cancel sockets. Returns 0 if interrupted, -1 if canceled by a handler. 1890 1891``` 1892nothing my_zloop.test (Boolean) 1893``` 1894 1895Self test of this class. 1896 1897### The Zmsg class - working with multipart messages 1898 1899Constructor: 1900 1901``` 1902var czmq = require ('bindings')('czmq') 1903var my_zmsg = new czmq.Zmsg () 1904``` 1905 1906You *must* call the destructor on every Zmsg instance: 1907 1908``` 1909my_zmsg.destroy () 1910``` 1911 1912Methods: 1913 1914``` 1915integer my_zmsg.send (Zmsg, Zsock) 1916``` 1917 1918Send message to destination socket, and destroy the message after sending 1919it successfully. If the message has no frames, sends nothing but destroys 1920the message anyhow. Nullifies the caller's reference to the message (as 1921it is a destructor). 1922 1923``` 1924integer my_zmsg.sendm (Zmsg, Zsock) 1925``` 1926 1927Send message to destination socket as part of a multipart sequence, and 1928destroy the message after sending it successfully. Note that after a 1929zmsg_sendm, you must call zmsg_send or another method that sends a final 1930message part. If the message has no frames, sends nothing but destroys 1931the message anyhow. Nullifies the caller's reference to the message (as 1932it is a destructor). 1933 1934``` 1935size my_zmsg.size () 1936``` 1937 1938Return size of message, i.e. number of frames (0 or more). 1939 1940``` 1941size my_zmsg.contentSize () 1942``` 1943 1944Return total size of all frames in message. 1945 1946``` 1947number my_zmsg.routingId () 1948``` 1949 1950Return message routing ID, if the message came from a ZMQ_SERVER socket. 1951Else returns zero. 1952 1953``` 1954nothing my_zmsg.setRoutingId (Number) 1955``` 1956 1957Set routing ID on message. This is used if/when the message is sent to a 1958ZMQ_SERVER socket. 1959 1960``` 1961integer my_zmsg.prepend (Zframe) 1962``` 1963 1964Push frame to the front of the message, i.e. before all other frames. 1965Message takes ownership of frame, will destroy it when message is sent. 1966Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not 1967nullify the caller's frame reference. 1968 1969``` 1970integer my_zmsg.append (Zframe) 1971``` 1972 1973Add frame to the end of the message, i.e. after all other frames. 1974Message takes ownership of frame, will destroy it when message is sent. 1975Returns 0 on success. Deprecates zmsg_add, which did not nullify the 1976caller's frame reference. 1977 1978``` 1979zframe my_zmsg.pop () 1980``` 1981 1982Remove first frame from message, if any. Returns frame, or NULL. 1983 1984``` 1985integer my_zmsg.pushmem (String) 1986``` 1987 1988Push block of memory to front of message, as a new frame. 1989Returns 0 on success, -1 on error. 1990 1991``` 1992integer my_zmsg.addmem (String) 1993``` 1994 1995Add block of memory to the end of the message, as a new frame. 1996Returns 0 on success, -1 on error. 1997 1998``` 1999integer my_zmsg.pushstr (String) 2000``` 2001 2002Push string as new frame to front of message. 2003Returns 0 on success, -1 on error. 2004 2005``` 2006integer my_zmsg.addstr (String) 2007``` 2008 2009Push string as new frame to end of message. 2010Returns 0 on success, -1 on error. 2011 2012``` 2013integer my_zmsg.pushstrf (String) 2014``` 2015 2016Push formatted string as new frame to front of message. 2017Returns 0 on success, -1 on error. 2018 2019``` 2020integer my_zmsg.addstrf (String) 2021``` 2022 2023Push formatted string as new frame to end of message. 2024Returns 0 on success, -1 on error. 2025 2026``` 2027string my_zmsg.popstr () 2028``` 2029 2030Pop frame off front of message, return as fresh string. If there were 2031no more frames in the message, returns NULL. 2032 2033``` 2034integer my_zmsg.addmsg (Zmsg) 2035``` 2036 2037Push encoded message as a new frame. Message takes ownership of 2038submessage, so the original is destroyed in this call. Returns 0 on 2039success, -1 on error. 2040 2041``` 2042zmsg my_zmsg.popmsg () 2043``` 2044 2045Remove first submessage from message, if any. Returns zmsg_t, or NULL if 2046decoding was not successful. 2047 2048``` 2049nothing my_zmsg.remove (Zframe) 2050``` 2051 2052Remove specified frame from list, if present. Does not destroy frame. 2053 2054``` 2055zframe my_zmsg.first () 2056``` 2057 2058Set cursor to first frame in message. Returns frame, or NULL, if the 2059message is empty. Use this to navigate the frames as a list. 2060 2061``` 2062zframe my_zmsg.next () 2063``` 2064 2065Return the next frame. If there are no more frames, returns NULL. To move 2066to the first frame call zmsg_first(). Advances the cursor. 2067 2068``` 2069zframe my_zmsg.last () 2070``` 2071 2072Return the last frame. If there are no frames, returns NULL. 2073 2074``` 2075zframe my_zmsg.encode () 2076``` 2077 2078Serialize multipart message to a single message frame. Use this method 2079to send structured messages across transports that do not support 2080multipart data. Allocates and returns a new frame containing the 2081serialized message. To decode a serialized message frame, use 2082zmsg_decode (). 2083 2084``` 2085zmsg my_zmsg.dup () 2086``` 2087 2088Create copy of message, as new message object. Returns a fresh zmsg_t 2089object. If message is null, or memory was exhausted, returns null. 2090 2091``` 2092nothing my_zmsg.print () 2093``` 2094 2095Send message to zsys log sink (may be stdout, or system facility as 2096configured by zsys_set_logstream). 2097 2098``` 2099boolean my_zmsg.eq (Zmsg) 2100``` 2101 2102Return true if the two messages have the same number of frames and each 2103frame in the first message is identical to the corresponding frame in the 2104other message. As with zframe_eq, return false if either message is NULL. 2105 2106``` 2107integer my_zmsg.signal () 2108``` 2109 2110Return signal value, 0 or greater, if message is a signal, -1 if not. 2111 2112``` 2113nothing my_zmsg.test (Boolean) 2114``` 2115 2116Self test of this class. 2117 2118### The Zpoller class - event-driven reactor 2119 2120Constructor: 2121 2122``` 2123var czmq = require ('bindings')('czmq') 2124var my_zpoller = new czmq.Zpoller (Zsock) 2125``` 2126 2127You *must* call the destructor on every Zpoller instance: 2128 2129``` 2130my_zpoller.destroy () 2131``` 2132 2133Methods: 2134 2135``` 2136integer my_zpoller.add (Zsock) 2137``` 2138 2139Add a reader to be polled. Returns 0 if OK, -1 on failure. The reader may 2140be a libzmq void * socket, a zsock_t instance, or a zactor_t instance. 2141 2142``` 2143nothing my_zpoller.setNonstop (Boolean) 2144``` 2145 2146By default the poller stops if the process receives a SIGINT or SIGTERM 2147signal. This makes it impossible to shut-down message based architectures 2148like zactors. This method lets you switch off break handling. The default 2149nonstop setting is off (false). 2150 2151``` 2152boolean my_zpoller.expired () 2153``` 2154 2155Return true if the last zpoller_wait () call ended because the timeout 2156expired, without any error. 2157 2158``` 2159boolean my_zpoller.terminated () 2160``` 2161 2162Return true if the last zpoller_wait () call ended because the process 2163was interrupted, or the parent context was destroyed. 2164 2165``` 2166nothing my_zpoller.test (Boolean) 2167``` 2168 2169Self test of this class. 2170 2171### The Zproc class - process configuration and status 2172 2173Constructor: 2174 2175``` 2176var czmq = require ('bindings')('czmq') 2177var my_zproc = new czmq.Zproc () 2178``` 2179 2180You *must* call the destructor on every Zproc instance: 2181 2182``` 2183my_zproc.destroy () 2184``` 2185 2186Methods: 2187 2188``` 2189zlist my_zproc.args () 2190``` 2191 2192Return command line arguments (the first item is the executable) or 2193NULL if not set. 2194 2195``` 2196nothing my_zproc.setArgs (Zlist) 2197``` 2198 2199Setup the command line arguments, the first item must be an (absolute) filename 2200to run. 2201 2202``` 2203nothing my_zproc.setArgsx (String) 2204``` 2205 2206Setup the command line arguments, the first item must be an (absolute) filename 2207to run. Variadic function, must be NULL terminated. 2208 2209``` 2210nothing my_zproc.setEnv (Zhash) 2211``` 2212 2213Setup the environment variables for the process. 2214 2215``` 2216integer my_zproc.run () 2217``` 2218 2219Starts the process, return just before execve/CreateProcess. 2220 2221``` 2222integer my_zproc.returncode () 2223``` 2224 2225process exit code 2226 2227``` 2228integer my_zproc.pid () 2229``` 2230 2231PID of the process 2232 2233``` 2234boolean my_zproc.running () 2235``` 2236 2237return true if process is running, false if not yet started or finished 2238 2239``` 2240integer my_zproc.wait (Boolean) 2241``` 2242 2243wait or poll process status, return return code 2244 2245``` 2246nothing my_zproc.kill (Number) 2247``` 2248 2249send a signal to the subprocess 2250 2251``` 2252nothing my_zproc.setVerbose (Boolean) 2253``` 2254 2255set verbose mode 2256 2257``` 2258nothing my_zproc.test (Boolean) 2259``` 2260 2261Self test of this class. 2262 2263### The Zsock class - high-level socket API that hides libzmq contexts and sockets 2264 2265Constructor: 2266 2267``` 2268var czmq = require ('bindings')('czmq') 2269var my_zsock = new czmq.Zsock (Number) 2270``` 2271 2272You *must* call the destructor on every Zsock instance: 2273 2274``` 2275my_zsock.destroy () 2276``` 2277 2278Methods: 2279 2280``` 2281integer my_zsock.bind (String) 2282``` 2283 2284Bind a socket to a formatted endpoint. For tcp:// endpoints, supports 2285ephemeral ports, if you specify the port number as "*". By default 2286zsock uses the IANA designated range from C000 (49152) to FFFF (65535). 2287To override this range, follow the "*" with "[first-last]". Either or 2288both first and last may be empty. To bind to a random port within the 2289range, use "!" in place of "*". 2290 2291Examples: 2292 tcp://127.0.0.1:* bind to first free port from C000 up 2293 tcp://127.0.0.1:! bind to random port from C000 to FFFF 2294 tcp://127.0.0.1:*[60000-] bind to first free port from 60000 up 2295 tcp://127.0.0.1:![-60000] bind to random port from C000 to 60000 2296 tcp://127.0.0.1:![55000-55999] 2297 bind to random port from 55000 to 55999 2298 2299On success, returns the actual port number used, for tcp:// endpoints, 2300and 0 for other transports. On failure, returns -1. Note that when using 2301ephemeral ports, a port may be reused by different services without 2302clients being aware. Protocols that run on ephemeral ports should take 2303this into account. 2304 2305``` 2306string my_zsock.endpoint () 2307``` 2308 2309Returns last bound endpoint, if any. 2310 2311``` 2312integer my_zsock.unbind (String) 2313``` 2314 2315Unbind a socket from a formatted endpoint. 2316Returns 0 if OK, -1 if the endpoint was invalid or the function 2317isn't supported. 2318 2319``` 2320integer my_zsock.connect (String) 2321``` 2322 2323Connect a socket to a formatted endpoint 2324Returns 0 if OK, -1 if the endpoint was invalid. 2325 2326``` 2327integer my_zsock.disconnect (String) 2328``` 2329 2330Disconnect a socket from a formatted endpoint 2331Returns 0 if OK, -1 if the endpoint was invalid or the function 2332isn't supported. 2333 2334``` 2335integer my_zsock.attach (String, Boolean) 2336``` 2337 2338Attach a socket to zero or more endpoints. If endpoints is not null, 2339parses as list of ZeroMQ endpoints, separated by commas, and prefixed by 2340'@' (to bind the socket) or '>' (to connect the socket). Returns 0 if all 2341endpoints were valid, or -1 if there was a syntax error. If the endpoint 2342does not start with '@' or '>', the serverish argument defines whether 2343it is used to bind (serverish = true) or connect (serverish = false). 2344 2345``` 2346string my_zsock.typeStr () 2347``` 2348 2349Returns socket type as printable constant string. 2350 2351``` 2352integer my_zsock.send (String) 2353``` 2354 2355Send a 'picture' message to the socket (or actor). The picture is a 2356string that defines the type of each frame. This makes it easy to send 2357a complex multiframe message in one call. The picture can contain any 2358of these characters, each corresponding to one or two arguments: 2359 2360 i = int (signed) 2361 1 = uint8_t 2362 2 = uint16_t 2363 4 = uint32_t 2364 8 = uint64_t 2365 s = char * 2366 b = byte *, size_t (2 arguments) 2367 c = zchunk_t * 2368 f = zframe_t * 2369 h = zhashx_t * 2370 U = zuuid_t * 2371 p = void * (sends the pointer value, only meaningful over inproc) 2372 m = zmsg_t * (sends all frames in the zmsg) 2373 z = sends zero-sized frame (0 arguments) 2374 u = uint (deprecated) 2375 2376Note that s, b, c, and f are encoded the same way and the choice is 2377offered as a convenience to the sender, which may or may not already 2378have data in a zchunk or zframe. Does not change or take ownership of 2379any arguments. Returns 0 if successful, -1 if sending failed for any 2380reason. 2381 2382``` 2383integer my_zsock.recv (String) 2384``` 2385 2386Receive a 'picture' message to the socket (or actor). See zsock_send for 2387the format and meaning of the picture. Returns the picture elements into 2388a series of pointers as provided by the caller: 2389 2390 i = int * (stores signed integer) 2391 4 = uint32_t * (stores 32-bit unsigned integer) 2392 8 = uint64_t * (stores 64-bit unsigned integer) 2393 s = char ** (allocates new string) 2394 b = byte **, size_t * (2 arguments) (allocates memory) 2395 c = zchunk_t ** (creates zchunk) 2396 f = zframe_t ** (creates zframe) 2397 U = zuuid_t * (creates a zuuid with the data) 2398 h = zhashx_t ** (creates zhashx) 2399 p = void ** (stores pointer) 2400 m = zmsg_t ** (creates a zmsg with the remaing frames) 2401 z = null, asserts empty frame (0 arguments) 2402 u = uint * (stores unsigned integer, deprecated) 2403 2404Note that zsock_recv creates the returned objects, and the caller must 2405destroy them when finished with them. The supplied pointers do not need 2406to be initialized. Returns 0 if successful, or -1 if it failed to recv 2407a message, in which case the pointers are not modified. When message 2408frames are truncated (a short message), sets return values to zero/null. 2409If an argument pointer is NULL, does not store any value (skips it). 2410An 'n' picture matches an empty frame; if the message does not match, 2411the method will return -1. 2412 2413``` 2414integer my_zsock.bsend (String) 2415``` 2416 2417Send a binary encoded 'picture' message to the socket (or actor). This 2418method is similar to zsock_send, except the arguments are encoded in a 2419binary format that is compatible with zproto, and is designed to reduce 2420memory allocations. The pattern argument is a string that defines the 2421type of each argument. Supports these argument types: 2422 2423 pattern C type zproto type: 2424 1 uint8_t type = "number" size = "1" 2425 2 uint16_t type = "number" size = "2" 2426 4 uint32_t type = "number" size = "3" 2427 8 uint64_t type = "number" size = "4" 2428 s char *, 0-255 chars type = "string" 2429 S char *, 0-2^32-1 chars type = "longstr" 2430 c zchunk_t * type = "chunk" 2431 f zframe_t * type = "frame" 2432 u zuuid_t * type = "uuid" 2433 m zmsg_t * type = "msg" 2434 p void *, sends pointer value, only over inproc 2435 2436Does not change or take ownership of any arguments. Returns 0 if 2437successful, -1 if sending failed for any reason. 2438 2439``` 2440integer my_zsock.brecv (String) 2441``` 2442 2443Receive a binary encoded 'picture' message from the socket (or actor). 2444This method is similar to zsock_recv, except the arguments are encoded 2445in a binary format that is compatible with zproto, and is designed to 2446reduce memory allocations. The pattern argument is a string that defines 2447the type of each argument. See zsock_bsend for the supported argument 2448types. All arguments must be pointers; this call sets them to point to 2449values held on a per-socket basis. 2450For types 1, 2, 4 and 8 the caller must allocate the memory itself before 2451calling zsock_brecv. 2452For types S, the caller must free the value once finished with it, as 2453zsock_brecv will allocate the buffer. 2454For type s, the caller must not free the value as it is stored in a 2455local cache for performance purposes. 2456For types c, f, u and m the caller must call the appropriate destructor 2457depending on the object as zsock_brecv will create new objects. 2458For type p the caller must coordinate with the sender, as it is just a 2459pointer value being passed. 2460 2461``` 2462number my_zsock.routingId () 2463``` 2464 2465Return socket routing ID if any. This returns 0 if the socket is not 2466of type ZMQ_SERVER or if no request was already received on it. 2467 2468``` 2469nothing my_zsock.setRoutingId (Number) 2470``` 2471 2472Set routing ID on socket. The socket MUST be of type ZMQ_SERVER. 2473This will be used when sending messages on the socket via the zsock API. 2474 2475``` 2476nothing my_zsock.setUnbounded () 2477``` 2478 2479Set socket to use unbounded pipes (HWM=0); use this in cases when you are 2480totally certain the message volume can fit in memory. This method works 2481across all versions of ZeroMQ. Takes a polymorphic socket reference. 2482 2483``` 2484integer my_zsock.wait () 2485``` 2486 2487Wait on a signal. Use this to coordinate between threads, over pipe 2488pairs. Blocks until the signal is received. Returns -1 on error, 0 or 2489greater on success. Accepts a zsock_t or a zactor_t as argument. 2490Takes a polymorphic socket reference. 2491 2492``` 2493nothing my_zsock.flush () 2494``` 2495 2496If there is a partial message still waiting on the socket, remove and 2497discard it. This is useful when reading partial messages, to get specific 2498message types. 2499 2500``` 2501integer my_zsock.join (String) 2502``` 2503 2504Join a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. 2505Returns 0 if OK, -1 if failed. 2506 2507``` 2508integer my_zsock.leave (String) 2509``` 2510 2511Leave a group for the RADIO-DISH pattern. Call only on ZMQ_DISH. 2512Returns 0 if OK, -1 if failed. 2513 2514``` 2515integer my_zsock.heartbeatIvl () 2516``` 2517 2518Get socket option `heartbeat_ivl`. 2519Available from libzmq 4.2.0. 2520 2521``` 2522nothing my_zsock.setHeartbeatIvl (Number) 2523``` 2524 2525Set socket option `heartbeat_ivl`. 2526Available from libzmq 4.2.0. 2527 2528``` 2529integer my_zsock.heartbeatTtl () 2530``` 2531 2532Get socket option `heartbeat_ttl`. 2533Available from libzmq 4.2.0. 2534 2535``` 2536nothing my_zsock.setHeartbeatTtl (Number) 2537``` 2538 2539Set socket option `heartbeat_ttl`. 2540Available from libzmq 4.2.0. 2541 2542``` 2543integer my_zsock.heartbeatTimeout () 2544``` 2545 2546Get socket option `heartbeat_timeout`. 2547Available from libzmq 4.2.0. 2548 2549``` 2550nothing my_zsock.setHeartbeatTimeout (Number) 2551``` 2552 2553Set socket option `heartbeat_timeout`. 2554Available from libzmq 4.2.0. 2555 2556``` 2557integer my_zsock.useFd () 2558``` 2559 2560Get socket option `use_fd`. 2561Available from libzmq 4.2.0. 2562 2563``` 2564nothing my_zsock.setUseFd (Number) 2565``` 2566 2567Set socket option `use_fd`. 2568Available from libzmq 4.2.0. 2569 2570``` 2571nothing my_zsock.setXpubManual (Number) 2572``` 2573 2574Set socket option `xpub_manual`. 2575Available from libzmq 4.2.0. 2576 2577``` 2578nothing my_zsock.setXpubWelcomeMsg (String) 2579``` 2580 2581Set socket option `xpub_welcome_msg`. 2582Available from libzmq 4.2.0. 2583 2584``` 2585nothing my_zsock.setStreamNotify (Number) 2586``` 2587 2588Set socket option `stream_notify`. 2589Available from libzmq 4.2.0. 2590 2591``` 2592integer my_zsock.invertMatching () 2593``` 2594 2595Get socket option `invert_matching`. 2596Available from libzmq 4.2.0. 2597 2598``` 2599nothing my_zsock.setInvertMatching (Number) 2600``` 2601 2602Set socket option `invert_matching`. 2603Available from libzmq 4.2.0. 2604 2605``` 2606nothing my_zsock.setXpubVerboser (Number) 2607``` 2608 2609Set socket option `xpub_verboser`. 2610Available from libzmq 4.2.0. 2611 2612``` 2613integer my_zsock.connectTimeout () 2614``` 2615 2616Get socket option `connect_timeout`. 2617Available from libzmq 4.2.0. 2618 2619``` 2620nothing my_zsock.setConnectTimeout (Number) 2621``` 2622 2623Set socket option `connect_timeout`. 2624Available from libzmq 4.2.0. 2625 2626``` 2627integer my_zsock.tcpMaxrt () 2628``` 2629 2630Get socket option `tcp_maxrt`. 2631Available from libzmq 4.2.0. 2632 2633``` 2634nothing my_zsock.setTcpMaxrt (Number) 2635``` 2636 2637Set socket option `tcp_maxrt`. 2638Available from libzmq 4.2.0. 2639 2640``` 2641integer my_zsock.threadSafe () 2642``` 2643 2644Get socket option `thread_safe`. 2645Available from libzmq 4.2.0. 2646 2647``` 2648integer my_zsock.multicastMaxtpdu () 2649``` 2650 2651Get socket option `multicast_maxtpdu`. 2652Available from libzmq 4.2.0. 2653 2654``` 2655nothing my_zsock.setMulticastMaxtpdu (Number) 2656``` 2657 2658Set socket option `multicast_maxtpdu`. 2659Available from libzmq 4.2.0. 2660 2661``` 2662integer my_zsock.vmciBufferSize () 2663``` 2664 2665Get socket option `vmci_buffer_size`. 2666Available from libzmq 4.2.0. 2667 2668``` 2669nothing my_zsock.setVmciBufferSize (Number) 2670``` 2671 2672Set socket option `vmci_buffer_size`. 2673Available from libzmq 4.2.0. 2674 2675``` 2676integer my_zsock.vmciBufferMinSize () 2677``` 2678 2679Get socket option `vmci_buffer_min_size`. 2680Available from libzmq 4.2.0. 2681 2682``` 2683nothing my_zsock.setVmciBufferMinSize (Number) 2684``` 2685 2686Set socket option `vmci_buffer_min_size`. 2687Available from libzmq 4.2.0. 2688 2689``` 2690integer my_zsock.vmciBufferMaxSize () 2691``` 2692 2693Get socket option `vmci_buffer_max_size`. 2694Available from libzmq 4.2.0. 2695 2696``` 2697nothing my_zsock.setVmciBufferMaxSize (Number) 2698``` 2699 2700Set socket option `vmci_buffer_max_size`. 2701Available from libzmq 4.2.0. 2702 2703``` 2704integer my_zsock.vmciConnectTimeout () 2705``` 2706 2707Get socket option `vmci_connect_timeout`. 2708Available from libzmq 4.2.0. 2709 2710``` 2711nothing my_zsock.setVmciConnectTimeout (Number) 2712``` 2713 2714Set socket option `vmci_connect_timeout`. 2715Available from libzmq 4.2.0. 2716 2717``` 2718integer my_zsock.tos () 2719``` 2720 2721Get socket option `tos`. 2722Available from libzmq 4.1.0. 2723 2724``` 2725nothing my_zsock.setTos (Number) 2726``` 2727 2728Set socket option `tos`. 2729Available from libzmq 4.1.0. 2730 2731``` 2732nothing my_zsock.setRouterHandover (Number) 2733``` 2734 2735Set socket option `router_handover`. 2736Available from libzmq 4.1.0. 2737 2738``` 2739nothing my_zsock.setConnectRid (String) 2740``` 2741 2742Set socket option `connect_rid`. 2743Available from libzmq 4.1.0. 2744 2745``` 2746nothing my_zsock.setConnectRidBin (String) 2747``` 2748 2749Set socket option `connect_rid` from 32-octet binary 2750Available from libzmq 4.1.0. 2751 2752``` 2753integer my_zsock.handshakeIvl () 2754``` 2755 2756Get socket option `handshake_ivl`. 2757Available from libzmq 4.1.0. 2758 2759``` 2760nothing my_zsock.setHandshakeIvl (Number) 2761``` 2762 2763Set socket option `handshake_ivl`. 2764Available from libzmq 4.1.0. 2765 2766``` 2767string my_zsock.socksProxy () 2768``` 2769 2770Get socket option `socks_proxy`. 2771Available from libzmq 4.1.0. 2772 2773``` 2774nothing my_zsock.setSocksProxy (String) 2775``` 2776 2777Set socket option `socks_proxy`. 2778Available from libzmq 4.1.0. 2779 2780``` 2781nothing my_zsock.setXpubNodrop (Number) 2782``` 2783 2784Set socket option `xpub_nodrop`. 2785Available from libzmq 4.1.0. 2786 2787``` 2788nothing my_zsock.setRouterMandatory (Number) 2789``` 2790 2791Set socket option `router_mandatory`. 2792Available from libzmq 4.0.0. 2793 2794``` 2795nothing my_zsock.setProbeRouter (Number) 2796``` 2797 2798Set socket option `probe_router`. 2799Available from libzmq 4.0.0. 2800 2801``` 2802nothing my_zsock.setReqRelaxed (Number) 2803``` 2804 2805Set socket option `req_relaxed`. 2806Available from libzmq 4.0.0. 2807 2808``` 2809nothing my_zsock.setReqCorrelate (Number) 2810``` 2811 2812Set socket option `req_correlate`. 2813Available from libzmq 4.0.0. 2814 2815``` 2816nothing my_zsock.setConflate (Number) 2817``` 2818 2819Set socket option `conflate`. 2820Available from libzmq 4.0.0. 2821 2822``` 2823string my_zsock.zapDomain () 2824``` 2825 2826Get socket option `zap_domain`. 2827Available from libzmq 4.0.0. 2828 2829``` 2830nothing my_zsock.setZapDomain (String) 2831``` 2832 2833Set socket option `zap_domain`. 2834Available from libzmq 4.0.0. 2835 2836``` 2837integer my_zsock.mechanism () 2838``` 2839 2840Get socket option `mechanism`. 2841Available from libzmq 4.0.0. 2842 2843``` 2844integer my_zsock.plainServer () 2845``` 2846 2847Get socket option `plain_server`. 2848Available from libzmq 4.0.0. 2849 2850``` 2851nothing my_zsock.setPlainServer (Number) 2852``` 2853 2854Set socket option `plain_server`. 2855Available from libzmq 4.0.0. 2856 2857``` 2858string my_zsock.plainUsername () 2859``` 2860 2861Get socket option `plain_username`. 2862Available from libzmq 4.0.0. 2863 2864``` 2865nothing my_zsock.setPlainUsername (String) 2866``` 2867 2868Set socket option `plain_username`. 2869Available from libzmq 4.0.0. 2870 2871``` 2872string my_zsock.plainPassword () 2873``` 2874 2875Get socket option `plain_password`. 2876Available from libzmq 4.0.0. 2877 2878``` 2879nothing my_zsock.setPlainPassword (String) 2880``` 2881 2882Set socket option `plain_password`. 2883Available from libzmq 4.0.0. 2884 2885``` 2886integer my_zsock.curveServer () 2887``` 2888 2889Get socket option `curve_server`. 2890Available from libzmq 4.0.0. 2891 2892``` 2893nothing my_zsock.setCurveServer (Number) 2894``` 2895 2896Set socket option `curve_server`. 2897Available from libzmq 4.0.0. 2898 2899``` 2900string my_zsock.curvePublickey () 2901``` 2902 2903Get socket option `curve_publickey`. 2904Available from libzmq 4.0.0. 2905 2906``` 2907nothing my_zsock.setCurvePublickey (String) 2908``` 2909 2910Set socket option `curve_publickey`. 2911Available from libzmq 4.0.0. 2912 2913``` 2914nothing my_zsock.setCurvePublickeyBin (String) 2915``` 2916 2917Set socket option `curve_publickey` from 32-octet binary 2918Available from libzmq 4.0.0. 2919 2920``` 2921string my_zsock.curveSecretkey () 2922``` 2923 2924Get socket option `curve_secretkey`. 2925Available from libzmq 4.0.0. 2926 2927``` 2928nothing my_zsock.setCurveSecretkey (String) 2929``` 2930 2931Set socket option `curve_secretkey`. 2932Available from libzmq 4.0.0. 2933 2934``` 2935nothing my_zsock.setCurveSecretkeyBin (String) 2936``` 2937 2938Set socket option `curve_secretkey` from 32-octet binary 2939Available from libzmq 4.0.0. 2940 2941``` 2942string my_zsock.curveServerkey () 2943``` 2944 2945Get socket option `curve_serverkey`. 2946Available from libzmq 4.0.0. 2947 2948``` 2949nothing my_zsock.setCurveServerkey (String) 2950``` 2951 2952Set socket option `curve_serverkey`. 2953Available from libzmq 4.0.0. 2954 2955``` 2956nothing my_zsock.setCurveServerkeyBin (String) 2957``` 2958 2959Set socket option `curve_serverkey` from 32-octet binary 2960Available from libzmq 4.0.0. 2961 2962``` 2963integer my_zsock.gssapiServer () 2964``` 2965 2966Get socket option `gssapi_server`. 2967Available from libzmq 4.0.0. 2968 2969``` 2970nothing my_zsock.setGssapiServer (Number) 2971``` 2972 2973Set socket option `gssapi_server`. 2974Available from libzmq 4.0.0. 2975 2976``` 2977integer my_zsock.gssapiPlaintext () 2978``` 2979 2980Get socket option `gssapi_plaintext`. 2981Available from libzmq 4.0.0. 2982 2983``` 2984nothing my_zsock.setGssapiPlaintext (Number) 2985``` 2986 2987Set socket option `gssapi_plaintext`. 2988Available from libzmq 4.0.0. 2989 2990``` 2991string my_zsock.gssapiPrincipal () 2992``` 2993 2994Get socket option `gssapi_principal`. 2995Available from libzmq 4.0.0. 2996 2997``` 2998nothing my_zsock.setGssapiPrincipal (String) 2999``` 3000 3001Set socket option `gssapi_principal`. 3002Available from libzmq 4.0.0. 3003 3004``` 3005string my_zsock.gssapiServicePrincipal () 3006``` 3007 3008Get socket option `gssapi_service_principal`. 3009Available from libzmq 4.0.0. 3010 3011``` 3012nothing my_zsock.setGssapiServicePrincipal (String) 3013``` 3014 3015Set socket option `gssapi_service_principal`. 3016Available from libzmq 4.0.0. 3017 3018``` 3019integer my_zsock.ipv6 () 3020``` 3021 3022Get socket option `ipv6`. 3023Available from libzmq 4.0.0. 3024 3025``` 3026nothing my_zsock.setIpv6 (Number) 3027``` 3028 3029Set socket option `ipv6`. 3030Available from libzmq 4.0.0. 3031 3032``` 3033integer my_zsock.immediate () 3034``` 3035 3036Get socket option `immediate`. 3037Available from libzmq 4.0.0. 3038 3039``` 3040nothing my_zsock.setImmediate (Number) 3041``` 3042 3043Set socket option `immediate`. 3044Available from libzmq 4.0.0. 3045 3046``` 3047integer my_zsock.sndhwm () 3048``` 3049 3050Get socket option `sndhwm`. 3051Available from libzmq 3.0.0. 3052 3053``` 3054nothing my_zsock.setSndhwm (Number) 3055``` 3056 3057Set socket option `sndhwm`. 3058Available from libzmq 3.0.0. 3059 3060``` 3061integer my_zsock.rcvhwm () 3062``` 3063 3064Get socket option `rcvhwm`. 3065Available from libzmq 3.0.0. 3066 3067``` 3068nothing my_zsock.setRcvhwm (Number) 3069``` 3070 3071Set socket option `rcvhwm`. 3072Available from libzmq 3.0.0. 3073 3074``` 3075integer my_zsock.maxmsgsize () 3076``` 3077 3078Get socket option `maxmsgsize`. 3079Available from libzmq 3.0.0. 3080 3081``` 3082nothing my_zsock.setMaxmsgsize (Number) 3083``` 3084 3085Set socket option `maxmsgsize`. 3086Available from libzmq 3.0.0. 3087 3088``` 3089integer my_zsock.multicastHops () 3090``` 3091 3092Get socket option `multicast_hops`. 3093Available from libzmq 3.0.0. 3094 3095``` 3096nothing my_zsock.setMulticastHops (Number) 3097``` 3098 3099Set socket option `multicast_hops`. 3100Available from libzmq 3.0.0. 3101 3102``` 3103nothing my_zsock.setXpubVerbose (Number) 3104``` 3105 3106Set socket option `xpub_verbose`. 3107Available from libzmq 3.0.0. 3108 3109``` 3110integer my_zsock.tcpKeepalive () 3111``` 3112 3113Get socket option `tcp_keepalive`. 3114Available from libzmq 3.0.0. 3115 3116``` 3117nothing my_zsock.setTcpKeepalive (Number) 3118``` 3119 3120Set socket option `tcp_keepalive`. 3121Available from libzmq 3.0.0. 3122 3123``` 3124integer my_zsock.tcpKeepaliveIdle () 3125``` 3126 3127Get socket option `tcp_keepalive_idle`. 3128Available from libzmq 3.0.0. 3129 3130``` 3131nothing my_zsock.setTcpKeepaliveIdle (Number) 3132``` 3133 3134Set socket option `tcp_keepalive_idle`. 3135Available from libzmq 3.0.0. 3136 3137``` 3138integer my_zsock.tcpKeepaliveCnt () 3139``` 3140 3141Get socket option `tcp_keepalive_cnt`. 3142Available from libzmq 3.0.0. 3143 3144``` 3145nothing my_zsock.setTcpKeepaliveCnt (Number) 3146``` 3147 3148Set socket option `tcp_keepalive_cnt`. 3149Available from libzmq 3.0.0. 3150 3151``` 3152integer my_zsock.tcpKeepaliveIntvl () 3153``` 3154 3155Get socket option `tcp_keepalive_intvl`. 3156Available from libzmq 3.0.0. 3157 3158``` 3159nothing my_zsock.setTcpKeepaliveIntvl (Number) 3160``` 3161 3162Set socket option `tcp_keepalive_intvl`. 3163Available from libzmq 3.0.0. 3164 3165``` 3166string my_zsock.tcpAcceptFilter () 3167``` 3168 3169Get socket option `tcp_accept_filter`. 3170Available from libzmq 3.0.0. 3171 3172``` 3173nothing my_zsock.setTcpAcceptFilter (String) 3174``` 3175 3176Set socket option `tcp_accept_filter`. 3177Available from libzmq 3.0.0. 3178 3179``` 3180string my_zsock.lastEndpoint () 3181``` 3182 3183Get socket option `last_endpoint`. 3184Available from libzmq 3.0.0. 3185 3186``` 3187nothing my_zsock.setRouterRaw (Number) 3188``` 3189 3190Set socket option `router_raw`. 3191Available from libzmq 3.0.0. 3192 3193``` 3194integer my_zsock.ipv4only () 3195``` 3196 3197Get socket option `ipv4only`. 3198Available from libzmq 3.0.0. 3199 3200``` 3201nothing my_zsock.setIpv4only (Number) 3202``` 3203 3204Set socket option `ipv4only`. 3205Available from libzmq 3.0.0. 3206 3207``` 3208nothing my_zsock.setDelayAttachOnConnect (Number) 3209``` 3210 3211Set socket option `delay_attach_on_connect`. 3212Available from libzmq 3.0.0. 3213 3214``` 3215integer my_zsock.hwm () 3216``` 3217 3218Get socket option `hwm`. 3219Available from libzmq 2.0.0 to 3.0.0. 3220 3221``` 3222nothing my_zsock.setHwm (Number) 3223``` 3224 3225Set socket option `hwm`. 3226Available from libzmq 2.0.0 to 3.0.0. 3227 3228``` 3229integer my_zsock.swap () 3230``` 3231 3232Get socket option `swap`. 3233Available from libzmq 2.0.0 to 3.0.0. 3234 3235``` 3236nothing my_zsock.setSwap (Number) 3237``` 3238 3239Set socket option `swap`. 3240Available from libzmq 2.0.0 to 3.0.0. 3241 3242``` 3243integer my_zsock.affinity () 3244``` 3245 3246Get socket option `affinity`. 3247Available from libzmq 2.0.0. 3248 3249``` 3250nothing my_zsock.setAffinity (Number) 3251``` 3252 3253Set socket option `affinity`. 3254Available from libzmq 2.0.0. 3255 3256``` 3257string my_zsock.identity () 3258``` 3259 3260Get socket option `identity`. 3261Available from libzmq 2.0.0. 3262 3263``` 3264nothing my_zsock.setIdentity (String) 3265``` 3266 3267Set socket option `identity`. 3268Available from libzmq 2.0.0. 3269 3270``` 3271integer my_zsock.rate () 3272``` 3273 3274Get socket option `rate`. 3275Available from libzmq 2.0.0. 3276 3277``` 3278nothing my_zsock.setRate (Number) 3279``` 3280 3281Set socket option `rate`. 3282Available from libzmq 2.0.0. 3283 3284``` 3285integer my_zsock.recoveryIvl () 3286``` 3287 3288Get socket option `recovery_ivl`. 3289Available from libzmq 2.0.0. 3290 3291``` 3292nothing my_zsock.setRecoveryIvl (Number) 3293``` 3294 3295Set socket option `recovery_ivl`. 3296Available from libzmq 2.0.0. 3297 3298``` 3299integer my_zsock.recoveryIvlMsec () 3300``` 3301 3302Get socket option `recovery_ivl_msec`. 3303Available from libzmq 2.0.0 to 3.0.0. 3304 3305``` 3306nothing my_zsock.setRecoveryIvlMsec (Number) 3307``` 3308 3309Set socket option `recovery_ivl_msec`. 3310Available from libzmq 2.0.0 to 3.0.0. 3311 3312``` 3313integer my_zsock.mcastLoop () 3314``` 3315 3316Get socket option `mcast_loop`. 3317Available from libzmq 2.0.0 to 3.0.0. 3318 3319``` 3320nothing my_zsock.setMcastLoop (Number) 3321``` 3322 3323Set socket option `mcast_loop`. 3324Available from libzmq 2.0.0 to 3.0.0. 3325 3326``` 3327integer my_zsock.rcvtimeo () 3328``` 3329 3330Get socket option `rcvtimeo`. 3331Available from libzmq 2.2.0. 3332 3333``` 3334nothing my_zsock.setRcvtimeo (Number) 3335``` 3336 3337Set socket option `rcvtimeo`. 3338Available from libzmq 2.2.0. 3339 3340``` 3341integer my_zsock.sndtimeo () 3342``` 3343 3344Get socket option `sndtimeo`. 3345Available from libzmq 2.2.0. 3346 3347``` 3348nothing my_zsock.setSndtimeo (Number) 3349``` 3350 3351Set socket option `sndtimeo`. 3352Available from libzmq 2.2.0. 3353 3354``` 3355integer my_zsock.sndbuf () 3356``` 3357 3358Get socket option `sndbuf`. 3359Available from libzmq 2.0.0. 3360 3361``` 3362nothing my_zsock.setSndbuf (Number) 3363``` 3364 3365Set socket option `sndbuf`. 3366Available from libzmq 2.0.0. 3367 3368``` 3369integer my_zsock.rcvbuf () 3370``` 3371 3372Get socket option `rcvbuf`. 3373Available from libzmq 2.0.0. 3374 3375``` 3376nothing my_zsock.setRcvbuf (Number) 3377``` 3378 3379Set socket option `rcvbuf`. 3380Available from libzmq 2.0.0. 3381 3382``` 3383integer my_zsock.linger () 3384``` 3385 3386Get socket option `linger`. 3387Available from libzmq 2.0.0. 3388 3389``` 3390nothing my_zsock.setLinger (Number) 3391``` 3392 3393Set socket option `linger`. 3394Available from libzmq 2.0.0. 3395 3396``` 3397integer my_zsock.reconnectIvl () 3398``` 3399 3400Get socket option `reconnect_ivl`. 3401Available from libzmq 2.0.0. 3402 3403``` 3404nothing my_zsock.setReconnectIvl (Number) 3405``` 3406 3407Set socket option `reconnect_ivl`. 3408Available from libzmq 2.0.0. 3409 3410``` 3411integer my_zsock.reconnectIvlMax () 3412``` 3413 3414Get socket option `reconnect_ivl_max`. 3415Available from libzmq 2.0.0. 3416 3417``` 3418nothing my_zsock.setReconnectIvlMax (Number) 3419``` 3420 3421Set socket option `reconnect_ivl_max`. 3422Available from libzmq 2.0.0. 3423 3424``` 3425integer my_zsock.backlog () 3426``` 3427 3428Get socket option `backlog`. 3429Available from libzmq 2.0.0. 3430 3431``` 3432nothing my_zsock.setBacklog (Number) 3433``` 3434 3435Set socket option `backlog`. 3436Available from libzmq 2.0.0. 3437 3438``` 3439nothing my_zsock.setSubscribe (String) 3440``` 3441 3442Set socket option `subscribe`. 3443Available from libzmq 2.0.0. 3444 3445``` 3446nothing my_zsock.setUnsubscribe (String) 3447``` 3448 3449Set socket option `unsubscribe`. 3450Available from libzmq 2.0.0. 3451 3452``` 3453integer my_zsock.type () 3454``` 3455 3456Get socket option `type`. 3457Available from libzmq 2.0.0. 3458 3459``` 3460integer my_zsock.rcvmore () 3461``` 3462 3463Get socket option `rcvmore`. 3464Available from libzmq 2.0.0. 3465 3466``` 3467integer my_zsock.events () 3468``` 3469 3470Get socket option `events`. 3471Available from libzmq 2.0.0. 3472 3473``` 3474nothing my_zsock.test (Boolean) 3475``` 3476 3477Self test of this class. 3478 3479### The Zstr class - sending and receiving strings 3480 3481Constructor: 3482 3483``` 3484var czmq = require ('bindings')('czmq') 3485var my_zstr = new czmq.Zstr () 3486``` 3487 3488Methods: 3489 3490``` 3491string my_zstr.recv (Zsock) 3492``` 3493 3494Receive C string from socket. Caller must free returned string using 3495zstr_free(). Returns NULL if the context is being terminated or the 3496process was interrupted. 3497 3498``` 3499integer my_zstr.recvx (Zsock, String) 3500``` 3501 3502Receive a series of strings (until NULL) from multipart data. 3503Each string is allocated and filled with string data; if there 3504are not enough frames, unallocated strings are set to NULL. 3505Returns -1 if the message could not be read, else returns the 3506number of strings filled, zero or more. Free each returned string 3507using zstr_free(). If not enough strings are provided, remaining 3508multipart frames in the message are dropped. 3509 3510``` 3511string my_zstr.recvCompress (Zsock) 3512``` 3513 3514De-compress and receive C string from socket, received as a message 3515with two frames: size of the uncompressed string, and the string itself. 3516Caller must free returned string using zstr_free(). Returns NULL if the 3517context is being terminated or the process was interrupted. 3518 3519``` 3520integer my_zstr.send (Zsock, String) 3521``` 3522 3523Send a C string to a socket, as a frame. The string is sent without 3524trailing null byte; to read this you can use zstr_recv, or a similar 3525method that adds a null terminator on the received string. String 3526may be NULL, which is sent as "". 3527 3528``` 3529integer my_zstr.sendm (Zsock, String) 3530``` 3531 3532Send a C string to a socket, as zstr_send(), with a MORE flag, so that 3533you can send further strings in the same multi-part message. 3534 3535``` 3536integer my_zstr.sendf (Zsock, String) 3537``` 3538 3539Send a formatted string to a socket. Note that you should NOT use 3540user-supplied strings in the format (they may contain '%' which 3541will create security holes). 3542 3543``` 3544integer my_zstr.sendfm (Zsock, String) 3545``` 3546 3547Send a formatted string to a socket, as for zstr_sendf(), with a 3548MORE flag, so that you can send further strings in the same multi-part 3549message. 3550 3551``` 3552integer my_zstr.sendx (Zsock, String) 3553``` 3554 3555Send a series of strings (until NULL) as multipart data 3556Returns 0 if the strings could be sent OK, or -1 on error. 3557 3558``` 3559integer my_zstr.sendCompress (Zsock, String) 3560``` 3561 3562Compress and send a C string to a socket, as a message with two frames: 3563size of the uncompressed string, and the string itself. The string is 3564sent without trailing null byte; to read this you can use 3565zstr_recv_compress, or a similar method that de-compresses and adds a 3566null terminator on the received string. 3567 3568``` 3569integer my_zstr.sendmCompress (Zsock, String) 3570``` 3571 3572Compress and send a C string to a socket, as zstr_send_compress(), 3573with a MORE flag, so that you can send further strings in the same 3574multi-part message. 3575 3576``` 3577string my_zstr.str (Zsock) 3578``` 3579 3580Accepts a void pointer and returns a fresh character string. If source 3581is null, returns an empty string. 3582 3583``` 3584nothing my_zstr.free (String) 3585``` 3586 3587Free a provided string, and nullify the parent pointer. Safe to call on 3588a null pointer. 3589 3590``` 3591nothing my_zstr.test (Boolean) 3592``` 3593 3594Self test of this class. 3595 3596### The Zsys class - 3597 3598Constructor: 3599 3600``` 3601var czmq = require ('bindings')('czmq') 3602var my_zsys = new czmq.Zsys () 3603``` 3604 3605Methods: 3606 3607``` 3608nothing my_zsys.shutdown () 3609``` 3610 3611Optionally shut down the CZMQ zsys layer; this normally happens automatically 3612when the process exits; however this call lets you force a shutdown 3613earlier, avoiding any potential problems with atexit() ordering, especially 3614with Windows dlls. 3615 3616``` 3617string my_zsys.sockname (Number) 3618``` 3619 3620Return ZMQ socket name for socket type 3621*** This is for CZMQ internal use only and may change arbitrarily *** 3622 3623``` 3624zsock my_zsys.createPipe (Zsock) 3625``` 3626 3627Create a pipe, which consists of two PAIR sockets connected over inproc. 3628The pipe is configured to use the zsys_pipehwm setting. Returns the 3629frontend socket successful, NULL if failed. 3630 3631``` 3632nothing my_zsys.handlerReset () 3633``` 3634 3635Reset interrupt handler, call this at exit if needed 3636 3637``` 3638nothing my_zsys.catchInterrupts () 3639``` 3640 3641Set default interrupt handler, so Ctrl-C or SIGTERM will set 3642zsys_interrupted. Idempotent; safe to call multiple times. 3643Can be supressed by ZSYS_SIGHANDLER=false 3644*** This is for CZMQ internal use only and may change arbitrarily *** 3645 3646``` 3647boolean my_zsys.isInterrupted () 3648``` 3649 3650Check if default interrupt handler of Ctrl-C or SIGTERM was called. 3651Does not work if ZSYS_SIGHANDLER is false and code does not call 3652set interrupted on signal. 3653 3654``` 3655nothing my_zsys.setInterrupted () 3656``` 3657 3658Set interrupted flag. This is done by default signal handler, however 3659this can be handy for language bindings or cases without default 3660signal handler. 3661 3662``` 3663boolean my_zsys.fileExists (String) 3664``` 3665 3666Return 1 if file exists, else zero 3667 3668``` 3669time my_zsys.fileModified (String) 3670``` 3671 3672Return file modification time. Returns 0 if the file does not exist. 3673 3674``` 3675integer my_zsys.fileMode (String) 3676``` 3677 3678Return file mode; provides at least support for the POSIX S_ISREG(m) 3679and S_ISDIR(m) macros and the S_IRUSR and S_IWUSR bits, on all boxes. 3680Returns a mode_t cast to int, or -1 in case of error. 3681 3682``` 3683integer my_zsys.fileDelete (String) 3684``` 3685 3686Delete file. Does not complain if the file is absent 3687 3688``` 3689boolean my_zsys.fileStable (String) 3690``` 3691 3692Check if file is 'stable' 3693 3694``` 3695integer my_zsys.dirCreate (String) 3696``` 3697 3698Create a file path if it doesn't exist. The file path is treated as 3699printf format. 3700 3701``` 3702integer my_zsys.dirDelete (String) 3703``` 3704 3705Remove a file path if empty; the pathname is treated as printf format. 3706 3707``` 3708integer my_zsys.dirChange (String) 3709``` 3710 3711Move to a specified working directory. Returns 0 if OK, -1 if this failed. 3712 3713``` 3714nothing my_zsys.fileModePrivate () 3715``` 3716 3717Set private file creation mode; all files created from here will be 3718readable/writable by the owner only. 3719 3720``` 3721nothing my_zsys.fileModeDefault () 3722``` 3723 3724Reset default file creation mode; all files created from here will use 3725process file mode defaults. 3726 3727``` 3728nothing my_zsys.version (Number, Number, Number) 3729``` 3730 3731Return the CZMQ version for run-time API detection; returns version 3732number into provided fields, providing reference isn't null in each case. 3733 3734``` 3735string my_zsys.sprintf (String) 3736``` 3737 3738Format a string using printf formatting, returning a freshly allocated 3739buffer. If there was insufficient memory, returns NULL. Free the returned 3740string using zstr_free(). 3741 3742``` 3743nothing my_zsys.socketError (String) 3744``` 3745 3746Handle an I/O error on some socket operation; will report and die on 3747fatal errors, and continue silently on "try again" errors. 3748*** This is for CZMQ internal use only and may change arbitrarily *** 3749 3750``` 3751string my_zsys.hostname () 3752``` 3753 3754Return current host name, for use in public tcp:// endpoints. Caller gets 3755a freshly allocated string, should free it using zstr_free(). If the host 3756name is not resolvable, returns NULL. 3757 3758``` 3759integer my_zsys.daemonize (String) 3760``` 3761 3762Move the current process into the background. The precise effect depends 3763on the operating system. On POSIX boxes, moves to a specified working 3764directory (if specified), closes all file handles, reopens stdin, stdout, 3765and stderr to the null device, and sets the process to ignore SIGHUP. On 3766Windows, does nothing. Returns 0 if OK, -1 if there was an error. 3767 3768``` 3769integer my_zsys.runAs (String, String, String) 3770``` 3771 3772Drop the process ID into the lockfile, with exclusive lock, and switch 3773the process to the specified group and/or user. Any of the arguments 3774may be null, indicating a no-op. Returns 0 on success, -1 on failure. 3775Note if you combine this with zsys_daemonize, run after, not before 3776that method, or the lockfile will hold the wrong process ID. 3777 3778``` 3779boolean my_zsys.hasCurve () 3780``` 3781 3782Returns true if the underlying libzmq supports CURVE security. 3783Uses a heuristic probe according to the version of libzmq being used. 3784 3785``` 3786nothing my_zsys.setIoThreads () 3787``` 3788 3789Configure the number of I/O threads that ZeroMQ will use. A good 3790rule of thumb is one thread per gigabit of traffic in or out. The 3791default is 1, sufficient for most applications. If the environment 3792variable ZSYS_IO_THREADS is defined, that provides the default. 3793Note that this method is valid only before any socket is created. 3794 3795``` 3796nothing my_zsys.setThreadSchedPolicy (Number) 3797``` 3798 3799Configure the scheduling policy of the ZMQ context thread pool. 3800Not available on Windows. See the sched_setscheduler man page or sched.h 3801for more information. If the environment variable ZSYS_THREAD_SCHED_POLICY 3802is defined, that provides the default. 3803Note that this method is valid only before any socket is created. 3804 3805``` 3806nothing my_zsys.setThreadPriority (Number) 3807``` 3808 3809Configure the scheduling priority of the ZMQ context thread pool. 3810Not available on Windows. See the sched_setscheduler man page or sched.h 3811for more information. If the environment variable ZSYS_THREAD_PRIORITY is 3812defined, that provides the default. 3813Note that this method is valid only before any socket is created. 3814 3815``` 3816nothing my_zsys.setMaxSockets () 3817``` 3818 3819Configure the number of sockets that ZeroMQ will allow. The default 3820is 1024. The actual limit depends on the system, and you can query it 3821by using zsys_socket_limit (). A value of zero means "maximum". 3822Note that this method is valid only before any socket is created. 3823 3824``` 3825size my_zsys.socketLimit () 3826``` 3827 3828Return maximum number of ZeroMQ sockets that the system will support. 3829 3830``` 3831nothing my_zsys.setMaxMsgsz (Number) 3832``` 3833 3834Configure the maximum allowed size of a message sent. 3835The default is INT_MAX. 3836 3837``` 3838integer my_zsys.maxMsgsz () 3839``` 3840 3841Return maximum message size. 3842 3843``` 3844nothing my_zsys.setZeroCopyRecv (Number) 3845``` 3846 3847Configure whether to use zero copy strategy in libzmq. If the environment 3848variable ZSYS_ZERO_COPY_RECV is defined, that provides the default. 3849Otherwise the default is 1. 3850 3851``` 3852integer my_zsys.zeroCopyRecv () 3853``` 3854 3855Return ZMQ_ZERO_COPY_RECV option. 3856 3857``` 3858nothing my_zsys.setFileStableAgeMsec (Number) 3859``` 3860 3861Configure the threshold value of filesystem object age per st_mtime 3862that should elapse until we consider that object "stable" at the 3863current zclock_time() moment. 3864The default is S_DEFAULT_ZSYS_FILE_STABLE_AGE_MSEC defined in zsys.c 3865which generally depends on host OS, with fallback value of 5000. 3866 3867``` 3868msecs my_zsys.fileStableAgeMsec () 3869``` 3870 3871Return current threshold value of file stable age in msec. 3872This can be used in code that chooses to wait for this timeout 3873before testing if a filesystem object is "stable" or not. 3874 3875``` 3876nothing my_zsys.setLinger () 3877``` 3878 3879Configure the default linger timeout in msecs for new zsock instances. 3880You can also set this separately on each zsock_t instance. The default 3881linger time is zero, i.e. any pending messages will be dropped. If the 3882environment variable ZSYS_LINGER is defined, that provides the default. 3883Note that process exit will typically be delayed by the linger time. 3884 3885``` 3886nothing my_zsys.setSndhwm () 3887``` 3888 3889Configure the default outgoing pipe limit (HWM) for new zsock instances. 3890You can also set this separately on each zsock_t instance. The default 3891HWM is 1,000, on all versions of ZeroMQ. If the environment variable 3892ZSYS_SNDHWM is defined, that provides the default. Note that a value of 3893zero means no limit, i.e. infinite memory consumption. 3894 3895``` 3896nothing my_zsys.setRcvhwm () 3897``` 3898 3899Configure the default incoming pipe limit (HWM) for new zsock instances. 3900You can also set this separately on each zsock_t instance. The default 3901HWM is 1,000, on all versions of ZeroMQ. If the environment variable 3902ZSYS_RCVHWM is defined, that provides the default. Note that a value of 3903zero means no limit, i.e. infinite memory consumption. 3904 3905``` 3906nothing my_zsys.setPipehwm () 3907``` 3908 3909Configure the default HWM for zactor internal pipes; this is set on both 3910ends of the pipe, for outgoing messages only (sndhwm). The default HWM is 39111,000, on all versions of ZeroMQ. If the environment var ZSYS_ACTORHWM is 3912defined, that provides the default. Note that a value of zero means no 3913limit, i.e. infinite memory consumption. 3914 3915``` 3916size my_zsys.pipehwm () 3917``` 3918 3919Return the HWM for zactor internal pipes. 3920 3921``` 3922nothing my_zsys.setIpv6 (Number) 3923``` 3924 3925Configure use of IPv6 for new zsock instances. By default sockets accept 3926and make only IPv4 connections. When you enable IPv6, sockets will accept 3927and connect to both IPv4 and IPv6 peers. You can override the setting on 3928each zsock_t instance. The default is IPv4 only (ipv6 set to 0). If the 3929environment variable ZSYS_IPV6 is defined (as 1 or 0), this provides the 3930default. Note: has no effect on ZMQ v2. 3931 3932``` 3933integer my_zsys.ipv6 () 3934``` 3935 3936Return use of IPv6 for zsock instances. 3937 3938``` 3939nothing my_zsys.setInterface (String) 3940``` 3941 3942Set network interface name to use for broadcasts, particularly zbeacon. 3943This lets the interface be configured for test environments where required. 3944For example, on Mac OS X, zbeacon cannot bind to 255.255.255.255 which is 3945the default when there is no specified interface. If the environment 3946variable ZSYS_INTERFACE is set, use that as the default interface name. 3947Setting the interface to "*" means "use all available interfaces". 3948 3949``` 3950string my_zsys.interface () 3951``` 3952 3953Return network interface to use for broadcasts, or "" if none was set. 3954 3955``` 3956nothing my_zsys.setIpv6Address (String) 3957``` 3958 3959Set IPv6 address to use zbeacon socket, particularly for receiving zbeacon. 3960This needs to be set IPv6 is enabled as IPv6 can have multiple addresses 3961on a given interface. If the environment variable ZSYS_IPV6_ADDRESS is set, 3962use that as the default IPv6 address. 3963 3964``` 3965string my_zsys.ipv6Address () 3966``` 3967 3968Return IPv6 address to use for zbeacon reception, or "" if none was set. 3969 3970``` 3971nothing my_zsys.setIpv6McastAddress (String) 3972``` 3973 3974Set IPv6 milticast address to use for sending zbeacon messages. This needs 3975to be set if IPv6 is enabled. If the environment variable 3976ZSYS_IPV6_MCAST_ADDRESS is set, use that as the default IPv6 multicast 3977address. 3978 3979``` 3980string my_zsys.ipv6McastAddress () 3981``` 3982 3983Return IPv6 multicast address to use for sending zbeacon, or "" if none was 3984set. 3985 3986``` 3987nothing my_zsys.setAutoUseFd (Number) 3988``` 3989 3990Configure the automatic use of pre-allocated FDs when creating new sockets. 3991If 0 (default), nothing will happen. Else, when a new socket is bound, the 3992system API will be used to check if an existing pre-allocated FD with a 3993matching port (if TCP) or path (if IPC) exists, and if it does it will be 3994set via the ZMQ_USE_FD socket option so that the library will use it 3995instead of creating a new socket. 3996 3997``` 3998integer my_zsys.autoUseFd () 3999``` 4000 4001Return use of automatic pre-allocated FDs for zsock instances. 4002 4003``` 4004nothing my_zsys.setLogident (String) 4005``` 4006 4007Set log identity, which is a string that prefixes all log messages sent 4008by this process. The log identity defaults to the environment variable 4009ZSYS_LOGIDENT, if that is set. 4010 4011``` 4012nothing my_zsys.setLogsender (String) 4013``` 4014 4015Sends log output to a PUB socket bound to the specified endpoint. To 4016collect such log output, create a SUB socket, subscribe to the traffic 4017you care about, and connect to the endpoint. Log traffic is sent as a 4018single string frame, in the same format as when sent to stdout. The 4019log system supports a single sender; multiple calls to this method will 4020bind the same sender to multiple endpoints. To disable the sender, call 4021this method with a null argument. 4022 4023``` 4024nothing my_zsys.setLogsystem (Boolean) 4025``` 4026 4027Enable or disable logging to the system facility (syslog on POSIX boxes, 4028event log on Windows). By default this is disabled. 4029 4030``` 4031nothing my_zsys.error (String) 4032``` 4033 4034Log error condition - highest priority 4035 4036``` 4037nothing my_zsys.warning (String) 4038``` 4039 4040Log warning condition - high priority 4041 4042``` 4043nothing my_zsys.notice (String) 4044``` 4045 4046Log normal, but significant, condition - normal priority 4047 4048``` 4049nothing my_zsys.info (String) 4050``` 4051 4052Log informational message - low priority 4053 4054``` 4055nothing my_zsys.debug (String) 4056``` 4057 4058Log debug-level message - lowest priority 4059 4060``` 4061nothing my_zsys.test (Boolean) 4062``` 4063 4064Self test of this class. 4065 4066### The Ztimerset class - timer set 4067 4068Constructor: 4069 4070``` 4071var czmq = require ('bindings')('czmq') 4072var my_ztimerset = new czmq.Ztimerset () 4073``` 4074 4075You *must* call the destructor on every Ztimerset instance: 4076 4077``` 4078my_ztimerset.destroy () 4079``` 4080 4081Methods: 4082 4083``` 4084integer my_ztimerset.cancel (Number) 4085``` 4086 4087Cancel a timer. Returns 0 if OK, -1 on failure. 4088 4089``` 4090integer my_ztimerset.setInterval (Number) 4091``` 4092 4093Set timer interval. Returns 0 if OK, -1 on failure. 4094This method is slow, canceling the timer and adding a new one yield better performance. 4095 4096``` 4097integer my_ztimerset.reset (Number) 4098``` 4099 4100Reset timer to start interval counting from current time. Returns 0 if OK, -1 on failure. 4101This method is slow, canceling the timer and adding a new one yield better performance. 4102 4103``` 4104integer my_ztimerset.timeout () 4105``` 4106 4107Return the time until the next interval. 4108Should be used as timeout parameter for the zpoller wait method. 4109The timeout is in msec. 4110 4111``` 4112integer my_ztimerset.execute () 4113``` 4114 4115Invoke callback function of all timers which their interval has elapsed. 4116Should be call after zpoller wait method. 4117Returns 0 if OK, -1 on failure. 4118 4119``` 4120nothing my_ztimerset.test (Boolean) 4121``` 4122 4123Self test of this class. 4124 4125### The Ztrie class - simple trie for tokenizable strings 4126 4127Constructor: 4128 4129``` 4130var czmq = require ('bindings')('czmq') 4131var my_ztrie = new czmq.Ztrie (String) 4132``` 4133 4134You *must* call the destructor on every Ztrie instance: 4135 4136``` 4137my_ztrie.destroy () 4138``` 4139 4140Methods: 4141 4142``` 4143integer my_ztrie.removeRoute (String) 4144``` 4145 4146Removes a route from the trie and destroys its data. Returns -1 if the 4147route does not exists, otherwise 0. 4148the start of the list call zlist_first (). Advances the cursor. 4149 4150``` 4151boolean my_ztrie.matches (String) 4152``` 4153 4154Returns true if the path matches a route in the tree, otherwise false. 4155 4156``` 4157size my_ztrie.hitParameterCount () 4158``` 4159 4160Returns the count of parameters that a matched route has. 4161 4162``` 4163zhashx my_ztrie.hitParameters () 4164``` 4165 4166Returns the parameters of a matched route with named regexes from last 4167ztrie_matches. If the path did not match or the route did not contain any 4168named regexes, returns NULL. 4169 4170``` 4171string my_ztrie.hitAsteriskMatch () 4172``` 4173 4174Returns the asterisk matched part of a route, if there has been no match 4175or no asterisk match, returns NULL. 4176 4177``` 4178nothing my_ztrie.print () 4179``` 4180 4181Print the trie 4182 4183``` 4184nothing my_ztrie.test (Boolean) 4185``` 4186 4187Self test of this class. 4188 4189### The Zuuid class - UUID support class 4190 4191Constructor: 4192 4193``` 4194var czmq = require ('bindings')('czmq') 4195var my_zuuid = new czmq.Zuuid () 4196``` 4197 4198You *must* call the destructor on every Zuuid instance: 4199 4200``` 4201my_zuuid.destroy () 4202``` 4203 4204Methods: 4205 4206``` 4207nothing my_zuuid.set (String) 4208``` 4209 4210Set UUID to new supplied ZUUID_LEN-octet value. 4211 4212``` 4213integer my_zuuid.setStr (String) 4214``` 4215 4216Set UUID to new supplied string value skipping '-' and '{' '}' 4217optional delimiters. Return 0 if OK, else returns -1. 4218 4219``` 4220buffer my_zuuid.data () 4221``` 4222 4223Return UUID binary data. 4224 4225``` 4226size my_zuuid.size () 4227``` 4228 4229Return UUID binary size 4230 4231``` 4232string my_zuuid.str () 4233``` 4234 4235Returns UUID as string 4236 4237``` 4238string my_zuuid.strCanonical () 4239``` 4240 4241Return UUID in the canonical string format: 8-4-4-4-12, in lower 4242case. Caller does not modify or free returned value. See 4243http://en.wikipedia.org/wiki/Universally_unique_identifier 4244 4245``` 4246nothing my_zuuid.export (String) 4247``` 4248 4249Store UUID blob in target array 4250 4251``` 4252boolean my_zuuid.eq (String) 4253``` 4254 4255Check if UUID is same as supplied value 4256 4257``` 4258boolean my_zuuid.neq (String) 4259``` 4260 4261Check if UUID is different from supplied value 4262 4263``` 4264zuuid my_zuuid.dup () 4265``` 4266 4267Make copy of UUID object; if uuid is null, or memory was exhausted, 4268returns null. 4269 4270``` 4271nothing my_zuuid.test (Boolean) 4272``` 4273 4274Self test of this class. 4275