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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24 (defconstant hausnumero
156384712)
26 ;; On Windows platform some of the standard POSIX errnos are not defined.
28 ;; #define ENOTSUP (ZMQ_HAUSNUMERO + 1)
30 ;; #ifndef EPROTONOSUPPORT
31 ;; #define EPROTONOSUPPORT (ZMQ_HAUSNUMERO + 2)
34 ;; #define ENOBUFS (ZMQ_HAUSNUMERO + 3)
37 ;; #define ENETDOWN (ZMQ_HAUSNUMERO + 4)
40 ;; #define EADDRINUSE (ZMQ_HAUSNUMERO + 5)
42 ;; #ifndef EADDRNOTAVAIL
43 ;; #define EADDRNOTAVAIL (ZMQ_HAUSNUMERO + 6)
46 ;; Native 0MQ error codes.
47 (defconstant emthread
(+ hausnumero
50))
48 (defconstant efsm
(+ hausnumero
51))
49 (defconstant enocompatproto
(+ hausnumero
52))
51 (defcfun ("zmq_strerror" %strerror
) :pointer
54 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
55 ;; 0MQ message definition.
56 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
58 (defconstant max-vsm-size
30)
60 ;; Message types. These integers may be stored in 'content' member of the
61 ;; message instead of regular pointer to the data.
62 (defconstant delimiter
31)
69 (vsm-data :uchar
:count
30)) ;; FIXME max-vsm-size
71 (defcfun ("zmq_msg_init" msg-init
) :int
74 (defcfun* ("zmq_msg_init_size" %msg-init-size
) :int
78 (defcallback zmq-free
:void
((ptr :pointer
) (hint :pointer
))
79 (declare (ignorable hint
))
82 (defcfun ("zmq_msg_init_data" msg-init-data
) :int
86 (ffn :pointer
) ; zmq_free_fn
89 (defcfun* ("zmq_msg_close" %msg-close
) :int
92 (defcfun ("zmq_msg_move" %msg-move
) :int
96 (defcfun ("zmq_msg_copy" %msg-copy
) :int
100 (defcfun ("zmq_msg_data" %msg-data
) :pointer
103 (defcfun ("zmq_msg_size" %msg-size
) :int
106 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
107 ;; 0MQ infrastructure (a.k.a. context) initialisation & termination.
108 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
112 (defcfun* ("zmq_init" init
) :pointer
117 (defcfun ("zmq_term" term
) :int
120 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
121 ;; 0MQ socket definition.
122 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
124 ;; Creating a 0MQ socket.
125 ;; **********************
134 (defconstant upstream
7)
135 (defconstant downstream
8)
137 (defcfun* ("zmq_socket" socket
) :pointer
141 ;; Destroying the socket.
142 ;; **********************
144 (defcfun ("zmq_close" close
) :int
147 ;; Manipulating socket options.
148 ;; ****************************
150 ;; Available socket options, their types and default values.
155 (defconstant affinity
4)
156 (defconstant identity
5)
157 (defconstant subscribe
6)
158 (defconstant unsubscribe
7)
160 (defconstant recovery-ivl
9)
161 (defconstant mcast-loop
10)
162 (defconstant sndbuf
11)
163 (defconstant rcvbuf
12)
165 (defcfun* ("zmq_setsockopt" %setsockopt
) :int
171 ;; Creating connections.
172 ;; *********************
174 ;; Addresses are composed of the name of the protocol to use followed by ://
175 ;; and a protocol-specific address. Available protocols:
177 ;; tcp - the address is composed of IP address and port delimited by colon
178 ;; sign (:). The IP address can be a hostname (with 'connect') or
179 ;; a network interface name (with 'bind'). Examples "tcp://eth0:5555",
180 ;; "tcp://192.168.0.1:20000", "tcp://hq.mycompany.com:80".
182 ;; pgm & udp - both protocols have same address format. It's network interface
183 ;; to use, semicolon (;), multicast group IP address, colon (:) and
184 ;; port. Examples: "pgm://eth2;224.0.0.1:8000",
185 ;; "udp://192.168.0.111;224.1.1.1:5555".
187 (defcfun* ("zmq_bind" %bind
) :int
189 (addr :pointer
:char
))
191 (defcfun* ("zmq_connect" %connect
) :int
193 (addr :pointer
:char
))
195 ;; Sending and receiving messages.
196 ;; *******************************
198 (defconstant noblock
1)
200 (defcfun* ("zmq_send" %send
) :int
206 (defcfun* ("zmq_recv" %recv
) :int
212 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
214 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
216 (defconstant pollin
1)
217 (defconstant pollout
2)
218 (defconstant pollerr
4)
226 (defcfun ("zmq_poll" %poll
) :int
231 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
233 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
235 ;; Helper functions used by perf tests so that they don't have to care
236 ;; about minutiae of time-related functions on different OS platforms.
238 (defcfun ("zmq_stopwatch_start" stopwatch-start
) :pointer
)
240 (defcfun ("zmq_stopwatch_stop" stopwatch-stop
) :ulong
243 (defcfun ("zmq_sleep" sleep
) :void
246 (defcfun ("zmq_version" %version
) :void
251 (defcfun ("zmq_errno" errno
) :int
)