Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
fc7715b4
Commit
fc7715b4
authored
Sep 16, 2009
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git@github.com:sustrik/zeromq2
parents
f1c72d69
c6665f46
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
74 deletions
+67
-74
local_thr.rb
perf/ruby/local_thr.rb
+1
-1
pyzmq.cpp
python/pyzmq.cpp
+24
-9
rbzmq.cpp
ruby/rbzmq.cpp
+42
-64
No files found.
perf/ruby/local_thr.rb
View file @
fc7715b4
...
...
@@ -29,7 +29,7 @@ message_count = ARGV[2].to_i
ctx
=
Context
.
new
(
1
,
1
)
s
=
Socket
.
new
(
ctx
,
SUB
);
s
.
setsockopt
(
SUBSCRIBE
,
"*"
);
s
.
setsockopt
(
SUBSCRIBE
,
"*"
);
# Add your socket options here.
# For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM.
...
...
python/pyzmq.cpp
View file @
fc7715b4
...
...
@@ -139,15 +139,30 @@ PyObject *socket_setsockopt (socket_t *self, PyObject *args, PyObject *kwdict)
return
NULL
;
}
int
rc
;
if
(
PyInt_Check
(
optval
))
{
int
val
=
PyInt_AsLong
(
optval
);
rc
=
zmq_setsockopt
(
self
->
handle
,
option
,
&
val
,
sizeof
(
int
));
}
if
(
PyString_Check
(
optval
))
rc
=
zmq_setsockopt
(
self
->
handle
,
option
,
PyString_AsString
(
optval
),
PyString_Size
(
optval
));
else
{
int
rc
=
0
;
switch
(
option
)
{
case
ZMQ_HWM
:
case
ZMQ_LWM
:
case
ZMQ_SWAP
:
case
ZMQ_AFFINITY
:
case
ZMQ_RATE
:
case
ZMQ_RECOVERY_IVL
:
case
ZMQ_MCAST_LOOP
:
{
int
val
=
PyInt_AsLong
(
optval
);
rc
=
zmq_setsockopt
(
self
->
handle
,
option
,
&
val
,
sizeof
(
int
));
break
;
}
case
ZMQ_IDENTITY
:
case
ZMQ_SUBSCRIBE
:
case
ZMQ_UNSUBSCRIBE
:
rc
=
zmq_setsockopt
(
self
->
handle
,
option
,
PyString_AsString
(
optval
),
PyString_Size
(
optval
));
break
;
default:
rc
=
-
1
;
errno
=
EINVAL
;
}
...
...
ruby/rbzmq.cpp
View file @
fc7715b4
...
...
@@ -83,74 +83,52 @@ static VALUE socket_initialize (VALUE self_, VALUE context_, VALUE type_)
return
self_
;
}
/*
static VALUE
rb_setsockopt (VALUE self_, VALUE socket
_, VALUE option_,
static
VALUE
socket_setsockopt
(
VALUE
self
_
,
VALUE
option_
,
VALUE
optval_
)
{
// Get the socket.
void* socket;
Data_Get_Struct (socket_, void*, socket);
int
rc
=
0
;
if (TYPE (optval_) == T_STRING) {
// Forward the code to native 0MQ library.
rc = zmq_setsockopt (socket, NUM2INT (option_),
(void *) StringValueCStr (optval_), RSTRING_LEN (optval_));
}
else if (TYPE (optval_) == T_FLOAT) {
double optval = NUM2DBL (optval_);
// Forward the code to native 0MQ library.
rc = zmq_setsockopt (socket, NUM2INT (option_),
(void*) &optval, 8);
}
else if (TYPE (optval_) == T_FIXNUM) {
long optval = FIX2LONG (optval_);
// Forward the code to native 0MQ library.
rc = zmq_setsockopt (socket, NUM2INT (option_),
(void *) &optval, 4);
}
else if (TYPE (optval_) == T_BIGNUM) {
long optval = NUM2LONG (optval_);
// Forward the code to native 0MQ library.
rc = zmq_setsockopt (socket, NUM2INT (option_),
(void *) &optval, 4);
}
else if (TYPE (optval_) == T_ARRAY) {
// Forward the code to native 0MQ library.
rc = zmq_setsockopt (socket, NUM2INT (option_),
(void *) RARRAY_PTR (optval_), RARRAY_LEN (optval_));
}
else if (TYPE (optval_) == T_STRUCT) {
// Forward the code to native 0MQ library.
rc = zmq_setsockopt (socket, NUM2INT (option_),
(void *) RSTRUCT_PTR (optval_), RSTRUCT_LEN (optval_));
}
else
rb_raise(rb_eRuntimeError, "Unknown type");
assert (rc == 0);
switch
(
NUM2INT
(
option_
))
{
case
ZMQ_HWM
:
case
ZMQ_LWM
:
case
ZMQ_SWAP
:
case
ZMQ_AFFINITY
:
case
ZMQ_RATE
:
case
ZMQ_RECOVERY_IVL
:
case
ZMQ_MCAST_LOOP
:
{
long
optval
=
FIX2LONG
(
optval_
);
// Forward the code to native 0MQ library.
rc
=
zmq_setsockopt
(
DATA_PTR
(
self_
),
NUM2INT
(
option_
),
(
void
*
)
&
optval
,
4
);
}
break
;
case
ZMQ_IDENTITY
:
case
ZMQ_SUBSCRIBE
:
case
ZMQ_UNSUBSCRIBE
:
// Forward the code to native 0MQ library.
rc
=
zmq_setsockopt
(
DATA_PTR
(
self_
),
NUM2INT
(
option_
),
(
void
*
)
StringValueCStr
(
optval_
),
RSTRING_LEN
(
optval_
));
break
;
default:
rc
=
-
1
;
errno
=
EINVAL
;
}
if
(
rc
!=
0
)
{
rb_raise
(
rb_eRuntimeError
,
strerror
(
errno
));
return
Qnil
;
}
return
self_
;
}
*/
static
VALUE
socket_bind
(
VALUE
self_
,
VALUE
addr_
)
{
...
...
@@ -264,8 +242,8 @@ extern "C" void Init_librbzmq ()
rb_define_alloc_func
(
socket_type
,
socket_alloc
);
rb_define_method
(
socket_type
,
"initialize"
,
(
VALUE
(
*
)(...))
socket_initialize
,
2
);
//
rb_define_method (socket_type, "setsockopt",
//
(VALUE(*)(...)) socket_setsockopt, 2);
rb_define_method
(
socket_type
,
"setsockopt"
,
(
VALUE
(
*
)(...))
socket_setsockopt
,
2
);
rb_define_method
(
socket_type
,
"bind"
,
(
VALUE
(
*
)(...))
socket_bind
,
1
);
rb_define_method
(
socket_type
,
"connect"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment