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
716f4ac8
Commit
716f4ac8
authored
Apr 09, 2010
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zmq_getsockopt function added
parent
027bb1d2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
122 additions
and
4 deletions
+122
-4
zmq.h
include/zmq.h
+2
-0
options.cpp
src/options.cpp
+104
-2
options.hpp
src/options.hpp
+1
-0
socket_base.cpp
src/socket_base.cpp
+7
-0
socket_base.hpp
src/socket_base.hpp
+2
-2
zmq.cpp
src/zmq.cpp
+6
-0
No files found.
include/zmq.h
View file @
716f4ac8
...
...
@@ -187,6 +187,8 @@ ZMQ_EXPORT void *zmq_socket (void *context, int type);
ZMQ_EXPORT
int
zmq_close
(
void
*
s
);
ZMQ_EXPORT
int
zmq_setsockopt
(
void
*
s
,
int
option
,
const
void
*
optval
,
size_t
optvallen
);
ZMQ_EXPORT
int
zmq_getsockopt
(
void
*
s
,
int
option
,
void
*
optval
,
size_t
*
optvallen
);
ZMQ_EXPORT
int
zmq_bind
(
void
*
s
,
const
char
*
addr
);
ZMQ_EXPORT
int
zmq_connect
(
void
*
s
,
const
char
*
addr
);
ZMQ_EXPORT
int
zmq_send
(
void
*
s
,
zmq_msg_t
*
msg
,
int
flags
);
...
...
src/options.cpp
View file @
716f4ac8
...
...
@@ -17,6 +17,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include "../include/zmq.h"
#include "options.hpp"
...
...
@@ -68,11 +70,11 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
return
0
;
case
ZMQ_AFFINITY
:
if
(
optvallen_
!=
sizeof
(
int64_t
))
{
if
(
optvallen_
!=
sizeof
(
u
int64_t
))
{
errno
=
EINVAL
;
return
-
1
;
}
affinity
=
(
uint64_t
)
*
((
int64_t
*
)
optval_
);
affinity
=
*
((
u
int64_t
*
)
optval_
);
return
0
;
case
ZMQ_IDENTITY
:
...
...
@@ -139,3 +141,103 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
errno
=
EINVAL
;
return
-
1
;
}
int
zmq
::
options_t
::
getsockopt
(
int
option_
,
void
*
optval_
,
size_t
*
optvallen_
)
{
switch
(
option_
)
{
case
ZMQ_HWM
:
if
(
*
optvallen_
<
sizeof
(
uint64_t
))
{
errno
=
EINVAL
;
return
-
1
;
}
*
((
uint64_t
*
)
optval_
)
=
hwm
;
*
optvallen_
=
sizeof
(
uint64_t
);
return
0
;
case
ZMQ_LWM
:
if
(
*
optvallen_
<
sizeof
(
uint64_t
))
{
errno
=
EINVAL
;
return
-
1
;
}
*
((
uint64_t
*
)
optval_
)
=
lwm
;
*
optvallen_
=
sizeof
(
uint64_t
);
return
0
;
case
ZMQ_SWAP
:
if
(
*
optvallen_
<
sizeof
(
int64_t
))
{
errno
=
EINVAL
;
return
-
1
;
}
*
((
int64_t
*
)
optval_
)
=
swap
;
*
optvallen_
=
sizeof
(
int64_t
);
return
0
;
case
ZMQ_AFFINITY
:
if
(
*
optvallen_
<
sizeof
(
uint64_t
))
{
errno
=
EINVAL
;
return
-
1
;
}
*
((
uint64_t
*
)
optval_
)
=
affinity
;
*
optvallen_
=
sizeof
(
uint64_t
);
return
0
;
case
ZMQ_IDENTITY
:
if
(
*
optvallen_
<
identity
.
size
())
{
errno
=
EINVAL
;
return
-
1
;
}
memcpy
(
optval_
,
identity
.
data
(),
identity
.
size
());
*
optvallen_
=
identity
.
size
();
return
0
;
case
ZMQ_RATE
:
if
(
*
optvallen_
<
sizeof
(
int64_t
))
{
errno
=
EINVAL
;
return
-
1
;
}
*
((
int64_t
*
)
optval_
)
=
rate
;
*
optvallen_
=
sizeof
(
int64_t
);
return
0
;
case
ZMQ_RECOVERY_IVL
:
if
(
*
optvallen_
<
sizeof
(
int64_t
))
{
errno
=
EINVAL
;
return
-
1
;
}
*
((
int64_t
*
)
optval_
)
=
recovery_ivl
;
*
optvallen_
=
sizeof
(
int64_t
);
return
0
;
case
ZMQ_MCAST_LOOP
:
if
(
*
optvallen_
<
sizeof
(
int64_t
))
{
errno
=
EINVAL
;
return
-
1
;
}
*
((
int64_t
*
)
optval_
)
=
use_multicast_loop
?
1
:
0
;
*
optvallen_
=
sizeof
(
int64_t
);
return
0
;
case
ZMQ_SNDBUF
:
if
(
*
optvallen_
<
sizeof
(
uint64_t
))
{
errno
=
EINVAL
;
return
-
1
;
}
*
((
uint64_t
*
)
optval_
)
=
sndbuf
;
*
optvallen_
=
sizeof
(
uint64_t
);
return
0
;
case
ZMQ_RCVBUF
:
if
(
*
optvallen_
<
sizeof
(
uint64_t
))
{
errno
=
EINVAL
;
return
-
1
;
}
*
((
uint64_t
*
)
optval_
)
=
rcvbuf
;
*
optvallen_
=
sizeof
(
uint64_t
);
return
0
;
}
errno
=
EINVAL
;
return
-
1
;
}
src/options.hpp
View file @
716f4ac8
...
...
@@ -32,6 +32,7 @@ namespace zmq
options_t
();
int
setsockopt
(
int
option_
,
const
void
*
optval_
,
size_t
optvallen_
);
int
getsockopt
(
int
option_
,
void
*
optval_
,
size_t
*
optvallen_
);
uint64_t
hwm
;
uint64_t
lwm
;
...
...
src/socket_base.cpp
View file @
716f4ac8
...
...
@@ -67,6 +67,13 @@ int zmq::socket_base_t::setsockopt (int option_, const void *optval_,
return
options
.
setsockopt
(
option_
,
optval_
,
optvallen_
);
}
int
zmq
::
socket_base_t
::
getsockopt
(
int
option_
,
void
*
optval_
,
size_t
*
optvallen_
)
{
// At the moment there are no socket-type-specific overloads of getsockopt.
return
options
.
getsockopt
(
option_
,
optval_
,
optvallen_
);
}
int
zmq
::
socket_base_t
::
bind
(
const
char
*
addr_
)
{
// Parse addr_ string.
...
...
src/socket_base.hpp
View file @
716f4ac8
...
...
@@ -47,8 +47,8 @@ namespace zmq
socket_base_t
(
class
app_thread_t
*
parent_
);
// Interface for communication with the API layer.
int
setsockopt
(
int
option_
,
const
void
*
optval_
,
size_t
optvallen_
);
int
setsockopt
(
int
option_
,
const
void
*
optval_
,
size_t
optvallen_
);
int
getsockopt
(
int
option_
,
void
*
optval_
,
size_t
*
optvallen_
);
int
bind
(
const
char
*
addr_
);
int
connect
(
const
char
*
addr_
);
int
send
(
zmq_msg_t
*
msg_
,
int
flags_
);
...
...
src/zmq.cpp
View file @
716f4ac8
...
...
@@ -305,6 +305,12 @@ int zmq_setsockopt (void *s_, int option_, const void *optval_,
optvallen_
));
}
int
zmq_getsockopt
(
void
*
s_
,
int
option_
,
void
*
optval_
,
size_t
*
optvallen_
)
{
return
(((
zmq
::
socket_base_t
*
)
s_
)
->
getsockopt
(
option_
,
optval_
,
optvallen_
));
}
int
zmq_bind
(
void
*
s_
,
const
char
*
addr_
)
{
return
(((
zmq
::
socket_base_t
*
)
s_
)
->
bind
(
addr_
));
...
...
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