1 ;; Copyright (c) 2009, 2010 Vitaly Mayatskikh <v.mayatskih@gmail.com>
3 ;; This file is part of 0MQ.
5 ;; 0MQ is free software; you can redistribute it and/or modify it under
6 ;; the terms of the Lesser GNU General Public License as published by
7 ;; the Free Software Foundation; either version 3 of the License, or
8 ;; (at your option) any later version.
10 ;; 0MQ is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; Lesser GNU General Public License for more details.
15 ;; You should have received a copy of the Lesser GNU General Public License
16 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
20 (defcvar "errno" :int
)
22 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26 (defconstant hausnumero
156384712)
28 ;; On Windows platform some of the standard POSIX errnos are not defined.
30 ;; #define ENOTSUP (ZMQ_HAUSNUMERO + 1)
32 ;; #ifndef EPROTONOSUPPORT
33 ;; #define EPROTONOSUPPORT (ZMQ_HAUSNUMERO + 2)
36 ;; #define ENOBUFS (ZMQ_HAUSNUMERO + 3)
39 ;; #define ENETDOWN (ZMQ_HAUSNUMERO + 4)
42 ;; #define EADDRINUSE (ZMQ_HAUSNUMERO + 5)
44 ;; #ifndef EADDRNOTAVAIL
45 ;; #define EADDRNOTAVAIL (ZMQ_HAUSNUMERO + 6)
48 ;; Native 0MQ error codes.
49 (defconstant emthread
(+ hausnumero
50))
50 (defconstant efsm
(+ hausnumero
51))
51 (defconstant enocompatproto
(+ hausnumero
52))
53 (defcfun ("zmq_strerror" %strerror
) :pointer
56 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
57 ;; 0MQ message definition.
58 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
60 (defconstant max-vsm-size
30)
62 ;; Message types. These integers may be stored in 'content' member of the
63 ;; message instead of regular pointer to the data.
64 (defconstant delimiter
31)
71 (vsm-data :uchar
:count
30)) ;; FIXME max-vsm-size
73 (defcfun ("zmq_msg_init" msg-init
) :int
76 (defcfun* ("zmq_msg_init_size" %msg-init-size
) :int
80 (defcallback zmq-free
:void
((ptr :pointer
) (hint :pointer
))
81 (declare (ignorable hint
))
84 (defcfun ("zmq_msg_init_data" msg-init-data
) :int
88 (ffn :pointer
) ; zmq_free_fn
91 (defcfun* ("zmq_msg_close" %msg-close
) :int
94 (defcfun ("zmq_msg_move" %msg-move
) :int
98 (defcfun ("zmq_msg_copy" %msg-copy
) :int
102 (defcfun ("zmq_msg_data" %msg-data
) :pointer
105 (defcfun ("zmq_msg_size" %msg-size
) :int
108 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
109 ;; 0MQ infrastructure (a.k.a. context) initialisation & termination.
110 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
114 (defcfun* ("zmq_init" init
) :pointer
119 (defcfun ("zmq_term" term
) :int
122 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
123 ;; 0MQ socket definition.
124 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
126 ;; Creating a 0MQ socket.
127 ;; **********************
136 (defconstant upstream
7)
137 (defconstant downstream
8)
139 (defcfun* ("zmq_socket" socket
) :pointer
143 ;; Destroying the socket.
144 ;; **********************
146 (defcfun ("zmq_close" close
) :int
149 ;; Manipulating socket options.
150 ;; ****************************
152 ;; Available socket options, their types and default values.
157 (defconstant affinity
4)
158 (defconstant identity
5)
159 (defconstant subscribe
6)
160 (defconstant unsubscribe
7)
162 (defconstant recovery-ivl
9)
163 (defconstant mcast-loop
10)
164 (defconstant sndbuf
11)
165 (defconstant rcvbuf
12)
167 (defcfun* ("zmq_setsockopt" %setsockopt
) :int
173 ;; Creating connections.
174 ;; *********************
176 ;; Addresses are composed of the name of the protocol to use followed by ://
177 ;; and a protocol-specific address. Available protocols:
179 ;; tcp - the address is composed of IP address and port delimited by colon
180 ;; sign (:). The IP address can be a hostname (with 'connect') or
181 ;; a network interface name (with 'bind'). Examples "tcp://eth0:5555",
182 ;; "tcp://192.168.0.1:20000", "tcp://hq.mycompany.com:80".
184 ;; pgm & udp - both protocols have same address format. It's network interface
185 ;; to use, semicolon (;), multicast group IP address, colon (:) and
186 ;; port. Examples: "pgm://eth2;224.0.0.1:8000",
187 ;; "udp://192.168.0.111;224.1.1.1:5555".
189 (defcfun* ("zmq_bind" %bind
) :int
191 (addr :pointer
:char
))
193 (defcfun* ("zmq_connect" %connect
) :int
195 (addr :pointer
:char
))
197 ;; Sending and receiving messages.
198 ;; *******************************
200 (defconstant noblock
1)
202 (defconstant noflush
2)
204 (defcfun* ("zmq_send" %send
) :int
210 (defcfun* ("zmq_flush" flush
) :int
213 (defcfun* ("zmq_recv" %recv
) :int
219 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
221 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
223 (defconstant pollin
1)
224 (defconstant pollout
2)
225 (defconstant pollerr
4)
233 (defcfun ("zmq_poll" %poll
) :int
238 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
240 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
242 ;; Helper functions used by perf tests so that they don't have to care
243 ;; about minutiae of time-related functions on different OS platforms.
245 (defcfun ("zmq_stopwatch_start" stopwatch-start
) :pointer
)
247 (defcfun ("zmq_stopwatch_stop" stopwatch-stop
) :ulong
250 (defcfun ("zmq_sleep" sleep
) :void
253 (defcfun ("zmq_version" %version
) :void