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
3147ff85
Commit
3147ff85
authored
Aug 09, 2009
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getsockopt implemented
parent
bde396f1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
5 deletions
+75
-5
zmq.h
include/zmq.h
+1
-0
socket_base.cpp
src/socket_base.cpp
+64
-5
socket_base.hpp
src/socket_base.hpp
+10
-0
No files found.
include/zmq.h
View file @
3147ff85
...
@@ -162,6 +162,7 @@ ZMQ_EXPORT void *zmq_socket (void *context, int type);
...
@@ -162,6 +162,7 @@ ZMQ_EXPORT void *zmq_socket (void *context, int type);
ZMQ_EXPORT
int
zmq_close
(
void
*
s
);
ZMQ_EXPORT
int
zmq_close
(
void
*
s
);
// Sets an option on the socket.
// Sets an option on the socket.
// EINVAL - unknown option, a value with incorrect length or an invalid value.
ZMQ_EXPORT
int
zmq_setsockopt
(
void
*
s
,
int
option_
,
void
*
optval_
,
ZMQ_EXPORT
int
zmq_setsockopt
(
void
*
s
,
int
option_
,
void
*
optval_
,
size_t
optvallen_
);
size_t
optvallen_
);
...
...
src/socket_base.cpp
View file @
3147ff85
...
@@ -26,12 +26,18 @@
...
@@ -26,12 +26,18 @@
#include "err.hpp"
#include "err.hpp"
#include "zmq_listener.hpp"
#include "zmq_listener.hpp"
#include "io_thread.hpp"
#include "io_thread.hpp"
#include "config.hpp"
zmq
::
socket_base_t
::
socket_base_t
(
app_thread_t
*
parent_
)
:
zmq
::
socket_base_t
::
socket_base_t
(
app_thread_t
*
parent_
)
:
object_t
(
parent_
),
object_t
(
parent_
),
pending_term_acks
(
0
),
pending_term_acks
(
0
),
app_thread
(
parent_
)
app_thread
(
parent_
),
{
hwm
(
0
),
lwm
(
0
),
swap
(
0
),
mask
(
0
),
affinity
(
0
)
{
}
}
zmq
::
socket_base_t
::~
socket_base_t
()
zmq
::
socket_base_t
::~
socket_base_t
()
...
@@ -63,14 +69,67 @@ zmq::socket_base_t::~socket_base_t ()
...
@@ -63,14 +69,67 @@ zmq::socket_base_t::~socket_base_t ()
int
zmq
::
socket_base_t
::
setsockopt
(
int
option_
,
void
*
optval_
,
int
zmq
::
socket_base_t
::
setsockopt
(
int
option_
,
void
*
optval_
,
size_t
optvallen_
)
size_t
optvallen_
)
{
{
zmq_assert
(
false
);
switch
(
option_
)
{
case
ZMQ_HWM
:
if
(
optvallen_
!=
sizeof
(
int64_t
))
{
errno
=
EINVAL
;
return
-
1
;
}
hwm
=
*
((
int64_t
*
)
optval_
);
return
0
;
case
ZMQ_LWM
:
if
(
optvallen_
!=
sizeof
(
int64_t
))
{
errno
=
EINVAL
;
return
-
1
;
}
lwm
=
*
((
int64_t
*
)
optval_
);
return
0
;
case
ZMQ_SWAP
:
if
(
optvallen_
!=
sizeof
(
int64_t
))
{
errno
=
EINVAL
;
return
-
1
;
}
swap
=
*
((
int64_t
*
)
optval_
);
return
0
;
case
ZMQ_MASK
:
if
(
optvallen_
!=
sizeof
(
int64_t
))
{
errno
=
EINVAL
;
return
-
1
;
}
mask
=
(
uint64_t
)
*
((
int64_t
*
)
optval_
);
return
0
;
case
ZMQ_AFFINITY
:
if
(
optvallen_
!=
sizeof
(
int64_t
))
{
errno
=
EINVAL
;
return
-
1
;
}
affinity
=
(
uint64_t
)
*
((
int64_t
*
)
optval_
);
return
0
;
case
ZMQ_SESSIONID
:
if
(
optvallen_
!=
sizeof
(
const
char
*
))
{
errno
=
EINVAL
;
return
-
1
;
}
session_id
=
(
const
char
*
)
optval_
;
return
0
;
default
:
errno
=
EINVAL
;
return
-
1
;
}
}
}
int
zmq
::
socket_base_t
::
bind
(
const
char
*
addr_
)
int
zmq
::
socket_base_t
::
bind
(
const
char
*
addr_
)
{
{
// TODO: The taskset should be taken from socket options.
// TODO: The taskset should be taken from socket options.
uint64_t
taskset
=
0
;
zmq_listener_t
*
listener
=
zmq_listener_t
*
listener
=
new
zmq_listener_t
(
choose_io_thread
(
taskset
),
this
);
new
zmq_listener_t
(
choose_io_thread
(
affinity
),
this
);
int
rc
=
listener
->
set_address
(
addr_
);
int
rc
=
listener
->
set_address
(
addr_
);
if
(
rc
!=
0
)
if
(
rc
!=
0
)
return
-
1
;
return
-
1
;
...
...
src/socket_base.hpp
View file @
3147ff85
...
@@ -21,9 +21,11 @@
...
@@ -21,9 +21,11 @@
#define __ZMQ_SOCKET_BASE_HPP_INCLUDED__
#define __ZMQ_SOCKET_BASE_HPP_INCLUDED__
#include <set>
#include <set>
#include <string>
#include "i_api.hpp"
#include "i_api.hpp"
#include "object.hpp"
#include "object.hpp"
#include "stdint.hpp"
namespace
zmq
namespace
zmq
{
{
...
@@ -64,6 +66,14 @@ namespace zmq
...
@@ -64,6 +66,14 @@ namespace zmq
// Application thread the socket lives in.
// Application thread the socket lives in.
class
app_thread_t
*
app_thread
;
class
app_thread_t
*
app_thread
;
// Socket options.
int64_t
hwm
;
int64_t
lwm
;
int64_t
swap
;
uint64_t
mask
;
uint64_t
affinity
;
std
::
string
session_id
;
socket_base_t
(
const
socket_base_t
&
);
socket_base_t
(
const
socket_base_t
&
);
void
operator
=
(
const
socket_base_t
&
);
void
operator
=
(
const
socket_base_t
&
);
};
};
...
...
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