123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765(* Copyright (c) 2011 Pedro Borges and contributors *)(** Module Exceptions *)typeerror=|EFSM|ENOCOMPATPROTO|ETERM|EMTHREAD|EUNKNOWNexceptionZMQ_exceptionoferror*stringexternalversion:unit->int*int*int="caml_zmq_version"moduleContext=structtypetexternalcreate:unit->t="caml_zmq_new"externalterminate:t->unit="caml_zmq_term"typeint_option=|ZMQ_IO_THREADS|ZMQ_MAX_SOCKETS|ZMQ_IPV6externalset_int_option:t->int_option->int->unit="caml_zmq_ctx_set_int_option"externalget_int_option:t->int_option->int="caml_zmq_ctx_get_int_option"letget_io_threadsctx=get_int_optionctxZMQ_IO_THREADSletset_io_threadsctx=set_int_optionctxZMQ_IO_THREADSletget_max_socketsctx=get_int_optionctxZMQ_MAX_SOCKETSletset_max_socketsctx=set_int_optionctxZMQ_MAX_SOCKETSletget_ipv6ctx=(get_int_optionctxZMQ_IPV6)==1letset_ipv6ctxhas_ipv6=set_int_optionctxZMQ_IPV6(ifhas_ipv6then1else0)endmoduleMsg=structopenBigarraytypettypebigstring=(char,int8_unsigned_elt,c_layout)Array1.texternalnative_init_data:bigstring->int->int->t="caml_zmq_msg_init_data"letinit_data?(offset=0)?lengthbuf=letlength=letmax_possible=Array1.dimbuf-offsetinmatchlengthwith|Somel->minlmax_possible|None->max_possibleinnative_init_databufoffsetlengthexternalsize:t->int="caml_zmq_msg_size"externalunsafe_data:t->bigstring="caml_zmq_msg_data"letcopy_datamsg=letdata=unsafe_datamsginletcopy=Array1.createcharc_layout(Array1.dimdata)inArray1.blitdatacopy;copyexternalclose:t->unit="caml_zmq_msg_close"externalgets:t->string->string="caml_zmq_msg_gets"endmoduleSocket=structtype+'at(** This is an int so we know which socket we
* are building inside the external functions *)type'akind=intletpair=0letpub=1letsub=2letreq=3letrep=4letdealer=5letrouter=6letpull=7letpush=8letxpub=9letxsub=10letstream=11(** Creation and Destruction *)externalcreate:Context.t->'akind->'at="caml_zmq_socket"externalclose:'at->unit="caml_zmq_close"(** Wiring *)externalconnect:'at->string->unit="caml_zmq_connect"externaldisconnect:'at->string->unit="caml_zmq_disconnect"externalbind:'at->string->unit="caml_zmq_bind"externalunbind:'at->string->unit="caml_zmq_unbind"(** Send and Receive *)externalnative_recv:'at->bool->string="caml_zmq_recv"letrecv?(block=true)socket=native_recvsocketblockexternalnative_send:'at->string->bool->bool->unit="caml_zmq_send"letsend?(block=true)?(more=false)socketmessage=native_sendsocketmessageblockmoreexternalnative_recv_msg:'at->bool->Msg.t="caml_zmq_recv_msg"letrecv_msg?(block=true)socket=native_recv_msgsocketblockexternalnative_send_msg:'at->Msg.t->bool->bool->unit="caml_zmq_send_msg"letsend_msg?(block=true)?(more=false)socketmessage=native_send_msgsocketmessageblockmoretypeint64_option=|ZMQ_AFFINITY|ZMQ_MAXMSGSIZEexternalset_int64_option:'at->int64_option->int->unit="caml_zmq_set_int64_option"externalget_int64_option:'at->int64_option->int="caml_zmq_get_int64_option"typestring_option=|ZMQ_IDENTITY|ZMQ_SUBSCRIBE|ZMQ_UNSUBSCRIBE|ZMQ_LAST_ENDPOINT|ZMQ_TCP_ACCEPT_FILTER|ZMQ_PLAIN_USERNAME|ZMQ_PLAIN_PASSWORD|ZMQ_CURVE_PUBLICKEY|ZMQ_CURVE_SECRETKEY|ZMQ_CURVE_SERVERKEY|ZMQ_ZAP_DOMAINexternalset_string_option:'at->string_option->string->unit="caml_zmq_set_string_option"externalget_string_option:'at->string_option->int->string="caml_zmq_get_string_option"[@@@warning"-37"]typeint_option=|ZMQ_RATE|ZMQ_RECOVERY_IVL|ZMQ_SNDBUF|ZMQ_RCVBUF|ZMQ_RCVMORE|ZMQ_EVENTS|ZMQ_TYPE|ZMQ_LINGER|ZMQ_RECONNECT_IVL|ZMQ_BACKLOG|ZMQ_RECONNECT_IVL_MAX|ZMQ_SNDHWM|ZMQ_RCVHWM|ZMQ_MULTICAST_HOPS|ZMQ_RCVTIMEO|ZMQ_SNDTIMEO|ZMQ_IPV6|ZMQ_ROUTER_MANDATORY|ZMQ_TCP_KEEPALIVE|ZMQ_TCP_KEEPALIVE_CNT|ZMQ_TCP_KEEPALIVE_IDLE|ZMQ_TCP_KEEPALIVE_INTVL|ZMQ_IMMEDIATE|ZMQ_XPUB_VERBOSE|ZMQ_MECHANISM|ZMQ_PLAIN_SERVER|ZMQ_CURVE_SERVER|ZMQ_PROBE_ROUTER|ZMQ_REQ_CORRELATE|ZMQ_REQ_RELAXED|ZMQ_CONFLATE[@@@warning"+37"]externalset_int_option:'at->int_option->int->unit="caml_zmq_set_int_option"externalget_int_option:'at->int_option->int="caml_zmq_get_int_option"letvalidate_string_lengthminmaxstrmsg=matchString.lengthstrwith|nwhenn<min->invalid_argmsg|nwhenn>max->invalid_argmsg|_->()letset_max_message_sizesocketsize=set_int64_optionsocketZMQ_MAXMSGSIZEsizeletget_max_message_sizesocket=get_int64_optionsocketZMQ_MAXMSGSIZEletset_affinitysocketsize=set_int64_optionsocketZMQ_AFFINITYsizeletget_affinitysocket=get_int64_optionsocketZMQ_AFFINITYletset_identitysocketidentity=validate_string_length1255identity"set_identity";set_string_optionsocketZMQ_IDENTITYidentityletmaximal_buffer_length=255letcurve_z85_buffer_length=41letget_identitysocket=get_string_optionsocketZMQ_IDENTITYmaximal_buffer_lengthletsubscribesockettopic=set_string_optionsocketZMQ_SUBSCRIBEtopicletunsubscribesockettopic=set_string_optionsocketZMQ_UNSUBSCRIBEtopicletget_last_endpointsocket=get_string_optionsocketZMQ_LAST_ENDPOINTmaximal_buffer_lengthletset_tcp_accept_filtersocketfilter=set_string_optionsocketZMQ_TCP_ACCEPT_FILTERfilterletset_ratesocketrate=set_int_optionsocketZMQ_RATErateletget_ratesocket=get_int_optionsocketZMQ_RATEletset_recovery_intervalsocketinterval=set_int_optionsocketZMQ_RECOVERY_IVLintervalletget_recovery_intervalsocket=get_int_optionsocketZMQ_RECOVERY_IVLletset_send_buffer_sizesocketsize=set_int_optionsocketZMQ_SNDBUFsizeletget_send_buffer_sizesocket=get_int_optionsocketZMQ_SNDBUFletset_receive_buffer_sizesocketsize=set_int_optionsocketZMQ_RCVBUFsizeletget_receive_buffer_sizesocket=get_int_optionsocketZMQ_RCVBUFlethas_moresocket=get_int_optionsocketZMQ_RCVMORE!=0letset_linger_periodsocketperiod=set_int_optionsocketZMQ_LINGERperiodletget_linger_periodsocket=get_int_optionsocketZMQ_LINGERletset_reconnect_intervalsocketinterval=set_int_optionsocketZMQ_RECONNECT_IVLintervalletget_reconnect_intervalsocket=get_int_optionsocketZMQ_RECONNECT_IVLletset_connection_backlogsocketbacklog=set_int_optionsocketZMQ_BACKLOGbacklogletget_connection_backlogsocket=get_int_optionsocketZMQ_BACKLOGletset_reconnect_interval_maxsocketinterval=set_int_optionsocketZMQ_RECONNECT_IVL_MAXintervalletget_reconnect_interval_maxsocket=get_int_optionsocketZMQ_RECONNECT_IVL_MAXletset_send_high_water_marksocketmark=set_int_optionsocketZMQ_SNDHWMmarkletget_send_high_water_marksocket=get_int_optionsocketZMQ_SNDHWMletset_receive_high_water_marksocketmark=set_int_optionsocketZMQ_RCVHWMmarkletget_receive_high_water_marksocket=get_int_optionsocketZMQ_RCVHWMletset_multicast_hopssockethops=set_int_optionsocketZMQ_MULTICAST_HOPShopsletget_multicast_hopssocket=get_int_optionsocketZMQ_MULTICAST_HOPSletset_receive_timeoutsockettimeout=set_int_optionsocketZMQ_RCVTIMEOtimeoutletget_receive_timeoutsocket=get_int_optionsocketZMQ_RCVTIMEOletset_send_timeoutsockettimeout=set_int_optionsocketZMQ_SNDTIMEOtimeoutletget_send_timeoutsocket=get_int_optionsocketZMQ_SNDTIMEOletset_ipv6socketflag=letvalue=matchflagwithtrue->1|false->0inset_int_optionsocketZMQ_IPV6valueletget_ipv6socket=matchget_int_optionsocketZMQ_IPV6with|0->false|_->trueletset_router_mandatorysocketflag=letvalue=matchflagwithtrue->1|false->0inset_int_optionsocketZMQ_ROUTER_MANDATORYvalueletget_router_mandatorysocket=matchget_int_optionsocketZMQ_ROUTER_MANDATORYwith|0->false|_->trueletset_tcp_keepalivesocketflag=letvalue=matchflagwith|`Default->-1|`Valuefalse->0|`Valuetrue->1inset_int_optionsocketZMQ_TCP_KEEPALIVEvalueletget_tcp_keepalivesocket=matchget_int_optionsocketZMQ_TCP_KEEPALIVEwith|-1->`Default|0->`Valuefalse|_->`Valuetrueletset_tcp_keepalive_idlesocketflag=letvalue=matchflagwith|`Default->-1|`Valuenwhenn<=0->invalid_arg"set_tcp_keepalive_idle"|`Valuen->ninset_int_optionsocketZMQ_TCP_KEEPALIVE_IDLEvalueletget_tcp_keepalive_idlesocket=matchget_int_optionsocketZMQ_TCP_KEEPALIVE_IDLEwith|-1->`Default|nwhenn<=0->assertfalse|n->`Valuenletset_tcp_keepalive_intervalsocketflag=letvalue=matchflagwith|`Default->-1|`Valuenwhenn<=0->invalid_arg"set_tcp_keepalive_interval"|`Valuen->ninset_int_optionsocketZMQ_TCP_KEEPALIVE_INTVLvalueletget_tcp_keepalive_intervalsocket=matchget_int_optionsocketZMQ_TCP_KEEPALIVE_INTVLwith|-1->`Default|nwhenn<=0->assertfalse|n->`Valuenletset_tcp_keepalive_countsocketflag=letvalue=matchflagwith|`Default->-1|`Valuenwhenn<=0->invalid_arg"set_tcp_keepalive_count"|`Valuen->ninset_int_optionsocketZMQ_TCP_KEEPALIVE_CNTvalueletget_tcp_keepalive_countsocket=matchget_int_optionsocketZMQ_TCP_KEEPALIVE_CNTwith|-1->`Default|nwhenn<=0->assertfalse|n->`Valuenletset_immediatesocketflag=letvalue=matchflagwith|true->1|false->0inset_int_optionsocketZMQ_IMMEDIATEvalueletget_immediatesocket=matchget_int_optionsocketZMQ_IMMEDIATEwith|0->false|_->trueletset_xpub_verbosesocketflag=letvalue=matchflagwith|true->1|false->0inset_int_optionsocketZMQ_XPUB_VERBOSEvalueletset_probe_routersocketflag=set_int_optionsocketZMQ_PROBE_ROUTER(ifflagthen1else0)letset_req_correlatesocketflag=set_int_optionsocketZMQ_REQ_CORRELATE(ifflagthen1else0)letset_req_relaxedsocketflag=set_int_optionsocketZMQ_REQ_RELAXED(ifflagthen1else0)letset_plain_serversocketflag=set_int_optionsocketZMQ_PLAIN_SERVER(ifflagthen1else0)letset_curve_serversocketflag=set_int_optionsocketZMQ_CURVE_SERVER(ifflagthen1else0)letset_plain_usernamesocket=set_string_optionsocketZMQ_PLAIN_USERNAMEletget_plain_usernamesocket=get_string_optionsocketZMQ_PLAIN_USERNAMEmaximal_buffer_lengthletset_plain_passwordsocket=set_string_optionsocketZMQ_PLAIN_PASSWORDletget_plain_passwordsocket=get_string_optionsocketZMQ_PLAIN_PASSWORDmaximal_buffer_lengthletvalidate_curve_key_lengthstrmsg=matchString.lengthstrwith|32|40->()|_->invalid_argmsgletget_curve_publickeysocket=get_string_optionsocketZMQ_CURVE_PUBLICKEYcurve_z85_buffer_lengthletset_curve_publickeysocketstr=validate_curve_key_lengthstr"set_curve_publickey";set_string_optionsocketZMQ_CURVE_PUBLICKEYstrletget_curve_secretkeysocket=get_string_optionsocketZMQ_CURVE_SECRETKEYcurve_z85_buffer_lengthletset_curve_secretkeysocketstr=validate_curve_key_lengthstr"set_curve_secretkey";set_string_optionsocketZMQ_CURVE_SECRETKEYstrletget_curve_serverkeysocket=get_string_optionsocketZMQ_CURVE_SERVERKEYcurve_z85_buffer_lengthletset_curve_serverkeysocketstr=validate_curve_key_lengthstr"set_curve_serverkey";set_string_optionsocketZMQ_CURVE_SERVERKEYstrletget_mechanismsocket=matchget_int_optionsocketZMQ_MECHANISMwith|0->`Null|1->`Plain|2->`Curve|_->assertfalseletset_zap_domainsocket=set_string_optionsocketZMQ_ZAP_DOMAINletget_zap_domainsocket=get_string_optionsocketZMQ_ZAP_DOMAINmaximal_buffer_lengthletset_conflatesocketflag=set_int_optionsocketZMQ_CONFLATE(ifflagthen1else0)externalget_fd:'at->Unix.file_descr="caml_zmq_get_fd"typeevent=No_event|Poll_in|Poll_out|Poll_in_out|Poll_errorexternalevents:'at->event="caml_zmq_get_events"letrecv_all_wrapper(f:?block:bool->_t->_)=(* Once the first message part is received all remaining message parts can
be received without blocking. *)letrecloopsocketaccu=ifhas_moresocketthenloopsocket(fsocket::accu)elseaccuinfun?blocksocket->letfirst=f?blocksocketinList.rev(loopsocket[first])letsend_all_wrapper(f:?block:bool->?more:bool->_t->_->unit)=(* Once the first message part is sent all remaining message parts can
be sent without blocking. *)letrecsend_all_inner_loopsocketmessage=matchmessagewith|[]->()|hd::[]->fsockethd|hd::tl->f~more:truesockethd;send_all_inner_loopsockettlinfun?blocksocketmessage->matchmessagewith|[]->()|hd::[]->f?block~more:falsesockethd|hd::tl->f?block~more:truesockethd;send_all_inner_loopsockettlletrecv_all?blocksocket=recv_all_wrapperrecv?blocksocketletsend_all?blocksocketmessage=send_all_wrappersend?blocksocketmessageletrecv_msg_all?blocksocket=recv_all_wrapperrecv_msg?blocksocketletsend_msg_all?blocksocketmessage=send_all_wrappersend_msg?blocksocketmessageendmoduleProxy=structexternalzmq_proxy2:'aSocket.t->'bSocket.t->unit="caml_zmq_proxy2"externalzmq_proxy3:'aSocket.t->'bSocket.t->'cSocket.t->unit="caml_zmq_proxy3"letcreate?capturefrontendbackend=matchcapturewith|Somecapture->zmq_proxy3frontendbackendcapture|None->zmq_proxy2frontendbackendendmodulePoll=structtypettypepoll_event=In|Out|In_outtype'apoll_mask=('aSocket.t*poll_event)letmask_in_outt=(t:>[`Pair|`Pub|`Sub|`Req|`Rep|`Dealer|`Router|`Pull|`Push|`Xsub|`Xpub|`Stream]Socket.t),In_outletmask_int=(t:>[`Pair|`Pub|`Sub|`Req|`Rep|`Dealer|`Router|`Pull|`Push|`Xsub|`Xpub|`Stream]Socket.t),Inletmask_outt=(t:>[`Pair|`Pub|`Sub|`Req|`Rep|`Dealer|`Router|`Pull|`Push|`Xsub|`Xpub|`Stream]Socket.t),Outexternalmask_of:'apoll_maskarray->t="caml_zmq_poll_of_pollitem_array"externalof_masks:'apoll_maskarray->t="caml_zmq_poll_of_pollitem_array"externalnative_poll:t->int->poll_eventoptionarray="caml_zmq_poll"letpoll?(timeout=-1)items=native_pollitemstimeoutendmoduleMonitor=structtypet=stringtypeaddress=stringtypeerror_no=inttypeerror_text=stringtypeevent=|Connectedofaddress*Unix.file_descr|Connect_delayedofaddress|Connect_retriedofaddress*int(*interval*)|Listeningofaddress*Unix.file_descr|Bind_failedofaddress*error_no*error_text|Acceptedofaddress*Unix.file_descr|Accept_failedofaddress*error_no*error_text|Closedofaddress*Unix.file_descr|Close_failedofaddress*error_no*error_text|Disconnectedofaddress*Unix.file_descr|Monitor_stoppedofaddress|Handshake_failed_no_detailofaddress|Handshake_succeededofaddress|Handshake_failed_protocolofaddress*int|Handshake_failed_authofaddress*intexternalsocket_monitor:'aSocket.t->string->unit="caml_zmq_socket_monitor"letcreatesocket=(* Construct an anonymous inproc channel name *)letsocket_id=Hashtbl.hash(Socket.get_fdsocket)inletaddress=Printf.sprintf"inproc://_socket_monitor-%d-%x.%x"(Unix.getpid())socket_id(Random.bits())insocket_monitorsocketaddress;addressletconnectctxt=lets=Socket.createctxSocket.pairinSocket.connectst;sexternaldecode_monitor_event:string->string->event="caml_decode_monitor_event"letrecv?blocksocket=letevent=Socket.recv?blocksocketinassert(Socket.has_moresocket);letaddr=Socket.recv~block:falsesocketindecode_monitor_eventeventaddrletget_peer_addressfd=tryletsockaddr=Unix.getpeernamefdinletdomain=matchUnix.domain_of_sockaddrsockaddrwith|Unix.PF_UNIX->"unix"|Unix.PF_INET->"tcp"|Unix.PF_INET6->"tcp6"inmatchsockaddrwith|Unix.ADDR_UNIXs->Printf.sprintf"%s://%s"domains;|Unix.ADDR_INET(addr,port)->Printf.sprintf"%s://%s:%d"domain(Unix.string_of_inet_addraddr)portwith|Unix.Unix_error_->"unknown"letinternal_string_of_eventpush_addresspop_address=function|Connected(addr,fd)->Printf.sprintf"Connect: %s. peer %s"addr(push_addressfd)|Connect_delayedaddr->Printf.sprintf"Connect delayed: %s"addr|Connect_retried(addr,interval)->Printf.sprintf"Connect retried: %s - %d"addrinterval|Listening(addr,fd)->Printf.sprintf"Listening: %s - peer %s"addr(push_addressfd)|Bind_failed(addr,error_no,error_text)->Printf.sprintf"Bind failed: %s. %d:%s"addrerror_noerror_text|Accepted(addr,fd)->Printf.sprintf"Accepted: %s. peer %s"addr(push_addressfd)|Accept_failed(addr,error_no,error_text)->Printf.sprintf"Accept failed: %s. %d:%s"addrerror_noerror_text|Closed(addr,fd)->Printf.sprintf"Closed: %s. peer %s"addr(pop_addressfd)|Close_failed(addr,error_no,error_text)->Printf.sprintf"Close failed: %s. %d:%s"addrerror_noerror_text|Disconnected(addr,fd)->Printf.sprintf"Disconnect: %s. peer %s"addr(pop_addressfd)|Monitor_stoppedaddr->Printf.sprintf"Monitor_stopped: %s"addr|Handshake_failed_no_detailaddr->Printf.sprintf"Handshake_failed_no_detail: %s"addr|Handshake_succeededaddr->Printf.sprintf"Handshake_succeeded: %s"addr|Handshake_failed_protocol(addr,code)->Printf.sprintf"Handshake_failed_protocol: %s - %d"addrcode|Handshake_failed_auth(addr,code)->Printf.sprintf"Handshake_failed_auth: %s - %d"addrcodeletstring_of_eventevent=internal_string_of_eventget_peer_addressget_peer_addresseventletmk_string_of_event()=letstate=ref[]inletpop_addressfd=letrecpopacc=function|[]->(get_peer_addressfd,acc)|(fd',address)::xswhenfd'=fd->(address,acc@xs)|x::xs->pop(x::acc)xsinlet(address,new_state)=pop[]!stateinstate:=new_state;addressinletpush_addressfd=letaddress=get_peer_addressfdinstate:=(fd,address)::!state;addressininternal_string_of_eventpush_addresspop_addressendmoduleZ85=structexternalencode:string->string="caml_z85_encode"externaldecode:string->string="caml_z85_decode"endmoduleCurve=structexternalkeypair:unit->string*string="caml_curve_keypair"end(* The following code is called by fail.c *)[@@@warning"-37"]typeinternal_error=(* zmq.h defines the following Unix error codes if they are not already defined
* by the system headers *)|I_ENOTSUP|I_EPROTONOSUPPORT|I_ENOBUFS|I_ENETDOWN|I_EADDRINUSE|I_EADDRNOTAVAIL|I_ECONNREFUSED|I_EINPROGRESS|I_ENOTSOCK|I_EMSGSIZE|I_EAFNOSUPPORT|I_ENETUNREACH|I_ECONNABORTED|I_ECONNRESET|I_ENOTCONN|I_ETIMEDOUT|I_EHOSTUNREACH|I_ENETRESET(* The following error codes are ZMQ-specific *)|I_EFSM|I_ENOCOMPATPROTO|I_ETERM|I_EMTHREAD|I_EUNKNOWN[@@@warning"+37"](* All Unix-type errors are mapped to their corresponding constructor in
* Unix -- except I_ENOTSUP, which is mapped to EOPNOTSUPP ("Operation not
* supported on socket") since there is no Unix.ENOTSUP.
* ZMQ-specific errors are mapped to the constructors of Zmq.error. *)letzmq_raiseestrfunc_name=letexn=matchewith|I_ENOTSUP->Unix.(Unix_error(EOPNOTSUPP,func_name,""))|I_EPROTONOSUPPORT->Unix.(Unix_error(EPROTONOSUPPORT,func_name,""))|I_ENOBUFS->Unix.(Unix_error(ENOBUFS,func_name,""))|I_ENETDOWN->Unix.(Unix_error(ENETDOWN,func_name,""))|I_EADDRINUSE->Unix.(Unix_error(EADDRINUSE,func_name,""))|I_EADDRNOTAVAIL->Unix.(Unix_error(EADDRNOTAVAIL,func_name,""))|I_ECONNREFUSED->Unix.(Unix_error(ECONNREFUSED,func_name,""))|I_EINPROGRESS->Unix.(Unix_error(EINPROGRESS,func_name,""))|I_ENOTSOCK->Unix.(Unix_error(ENOTSOCK,func_name,""))|I_EMSGSIZE->Unix.(Unix_error(EMSGSIZE,func_name,""))|I_EAFNOSUPPORT->Unix.(Unix_error(EAFNOSUPPORT,func_name,""))|I_ENETUNREACH->Unix.(Unix_error(ENETUNREACH,func_name,""))|I_ECONNABORTED->Unix.(Unix_error(ECONNABORTED,func_name,""))|I_ECONNRESET->Unix.(Unix_error(ECONNRESET,func_name,""))|I_ENOTCONN->Unix.(Unix_error(ENOTCONN,func_name,""))|I_ETIMEDOUT->Unix.(Unix_error(ETIMEDOUT,func_name,""))|I_EHOSTUNREACH->Unix.(Unix_error(EHOSTUNREACH,func_name,""))|I_ENETRESET->Unix.(Unix_error(ENETRESET,func_name,""))|I_EFSM->ZMQ_exception(EFSM,str)|I_ENOCOMPATPROTO->ZMQ_exception(ENOCOMPATPROTO,str)|I_ETERM->ZMQ_exception(ETERM,str)|I_EMTHREAD->ZMQ_exception(EMTHREAD,str)|I_EUNKNOWN->ZMQ_exception(EUNKNOWN,str)inraiseexnlet()=Callback.register"Zmq.zmq_raise"zmq_raise