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
b5d33739
Commit
b5d33739
authored
Feb 14, 2012
by
Ian Barber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moving to std::string in options
parent
770f8433
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
22 additions
and
18 deletions
+22
-18
zmq.h
include/zmq.h
+0
-3
ipc_listener.cpp
src/ipc_listener.cpp
+3
-2
ipc_listener.hpp
src/ipc_listener.hpp
+1
-1
options.cpp
src/options.cpp
+4
-4
options.hpp
src/options.hpp
+3
-2
socket_base.cpp
src/socket_base.cpp
+3
-2
tcp_listener.cpp
src/tcp_listener.cpp
+7
-3
tcp_listener.hpp
src/tcp_listener.hpp
+1
-1
No files found.
include/zmq.h
View file @
b5d33739
...
@@ -203,9 +203,6 @@ ZMQ_EXPORT int zmq_term (void *context);
...
@@ -203,9 +203,6 @@ ZMQ_EXPORT int zmq_term (void *context);
#define ZMQ_DONTWAIT 1
#define ZMQ_DONTWAIT 1
#define ZMQ_SNDMORE 2
#define ZMQ_SNDMORE 2
/* Wildcard endpoint support. */
#define ZMQ_ENDPOINT_MAX 256
ZMQ_EXPORT
void
*
zmq_socket
(
void
*
context
,
int
type
);
ZMQ_EXPORT
void
*
zmq_socket
(
void
*
context
,
int
type
);
ZMQ_EXPORT
int
zmq_close
(
void
*
s
);
ZMQ_EXPORT
int
zmq_close
(
void
*
s
);
ZMQ_EXPORT
int
zmq_setsockopt
(
void
*
s
,
int
option
,
const
void
*
optval
,
ZMQ_EXPORT
int
zmq_setsockopt
(
void
*
s
,
int
option
,
const
void
*
optval
,
...
...
src/ipc_listener.cpp
View file @
b5d33739
...
@@ -95,7 +95,7 @@ void zmq::ipc_listener_t::in_event ()
...
@@ -95,7 +95,7 @@ void zmq::ipc_listener_t::in_event ()
send_attach
(
session
,
engine
,
false
);
send_attach
(
session
,
engine
,
false
);
}
}
int
zmq
::
ipc_listener_t
::
get_address
(
unsigned
char
*
addr
,
size_t
*
len
)
int
zmq
::
ipc_listener_t
::
get_address
(
std
::
string
*
addr_
)
{
{
struct
sockaddr_un
sun
;
struct
sockaddr_un
sun
;
int
rc
;
int
rc
;
...
@@ -106,8 +106,9 @@ int zmq::ipc_listener_t::get_address (unsigned char *addr, size_t *len)
...
@@ -106,8 +106,9 @@ int zmq::ipc_listener_t::get_address (unsigned char *addr, size_t *len)
if
(
rc
!=
0
)
{
if
(
rc
!=
0
)
{
return
rc
;
return
rc
;
}
}
// Store the address for retrieval by users using wildcards
// Store the address for retrieval by users using wildcards
*
len
=
sprintf
((
char
*
)
addr
,
"ipc://%s"
,
sun
.
sun_path
);
*
addr_
=
std
::
string
(
"ipc://"
)
+
std
::
string
(
sun
.
sun_path
);
return
0
;
return
0
;
}
}
...
...
src/ipc_listener.hpp
View file @
b5d33739
...
@@ -50,7 +50,7 @@ namespace zmq
...
@@ -50,7 +50,7 @@ namespace zmq
int
set_address
(
const
char
*
addr_
);
int
set_address
(
const
char
*
addr_
);
// Get the bound address for use with wildcards
// Get the bound address for use with wildcards
int
get_address
(
unsigned
char
*
addr
,
size_t
*
len
);
int
get_address
(
std
::
string
*
addr_
);
private
:
private
:
...
...
src/options.cpp
View file @
b5d33739
...
@@ -30,7 +30,6 @@ zmq::options_t::options_t () :
...
@@ -30,7 +30,6 @@ zmq::options_t::options_t () :
rcvhwm
(
1000
),
rcvhwm
(
1000
),
affinity
(
0
),
affinity
(
0
),
identity_size
(
0
),
identity_size
(
0
),
last_endpoint_size
(
0
),
rate
(
100
),
rate
(
100
),
recovery_ivl
(
10000
),
recovery_ivl
(
10000
),
multicast_hops
(
1
),
multicast_hops
(
1
),
...
@@ -387,12 +386,13 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
...
@@ -387,12 +386,13 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
return
0
;
return
0
;
case
ZMQ_LAST_ENDPOINT
:
case
ZMQ_LAST_ENDPOINT
:
if
(
*
optvallen_
<
last_endpoint_size
)
{
// don't allow string which cannot contain the entire message
if
(
*
optvallen_
<
last_endpoint
.
size
()
+
1
)
{
errno
=
EINVAL
;
errno
=
EINVAL
;
return
-
1
;
return
-
1
;
}
}
memcpy
(
optval_
,
last_endpoint
,
last_endpoint_size
);
memcpy
(
optval_
,
last_endpoint
.
c_str
(),
last_endpoint
.
size
()
+
1
);
*
optvallen_
=
last_endpoint
_size
;
*
optvallen_
=
last_endpoint
.
size
()
+
1
;
return
0
;
return
0
;
}
}
...
...
src/options.hpp
View file @
b5d33739
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
#ifndef __ZMQ_OPTIONS_HPP_INCLUDED__
#ifndef __ZMQ_OPTIONS_HPP_INCLUDED__
#define __ZMQ_OPTIONS_HPP_INCLUDED__
#define __ZMQ_OPTIONS_HPP_INCLUDED__
#include <string>
#include "stddef.h"
#include "stddef.h"
#include "stdint.hpp"
#include "stdint.hpp"
...
@@ -48,8 +50,7 @@ namespace zmq
...
@@ -48,8 +50,7 @@ namespace zmq
unsigned
char
identity
[
256
];
unsigned
char
identity
[
256
];
// Last socket endpoint URI
// Last socket endpoint URI
unsigned
char
last_endpoint
[
256
];
std
::
string
last_endpoint
;
size_t
last_endpoint_size
;
// Maximum tranfer rate [kb/s]. Default 100kb/s.
// Maximum tranfer rate [kb/s]. Default 100kb/s.
int
rate
;
int
rate
;
...
...
src/socket_base.cpp
View file @
b5d33739
...
@@ -342,7 +342,7 @@ int zmq::socket_base_t::bind (const char *addr_)
...
@@ -342,7 +342,7 @@ int zmq::socket_base_t::bind (const char *addr_)
return
-
1
;
return
-
1
;
}
}
rc
=
listener
->
get_address
(
options
.
last_endpoint
,
&
(
options
.
last_endpoint_size
)
);
rc
=
listener
->
get_address
(
&
options
.
last_endpoint
);
launch_child
(
listener
);
launch_child
(
listener
);
return
0
;
return
0
;
}
}
...
@@ -357,7 +357,8 @@ int zmq::socket_base_t::bind (const char *addr_)
...
@@ -357,7 +357,8 @@ int zmq::socket_base_t::bind (const char *addr_)
delete
listener
;
delete
listener
;
return
-
1
;
return
-
1
;
}
}
rc
=
listener
->
get_address
(
options
.
last_endpoint
,
&
(
options
.
last_endpoint_size
));
rc
=
listener
->
get_address
(
&
options
.
last_endpoint
);
launch_child
(
listener
);
launch_child
(
listener
);
return
0
;
return
0
;
}
}
...
...
src/tcp_listener.cpp
View file @
b5d33739
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include <new>
#include <new>
#include <string.h>
#include <string.h>
#include <sstream>
#include "platform.hpp"
#include "platform.hpp"
#include "tcp_listener.hpp"
#include "tcp_listener.hpp"
...
@@ -119,11 +120,12 @@ void zmq::tcp_listener_t::close ()
...
@@ -119,11 +120,12 @@ void zmq::tcp_listener_t::close ()
s
=
retired_fd
;
s
=
retired_fd
;
}
}
int
zmq
::
tcp_listener_t
::
get_address
(
unsigned
char
*
addr
,
size_t
*
len
)
int
zmq
::
tcp_listener_t
::
get_address
(
std
::
string
*
addr_
)
{
{
struct
sockaddr
sa
;
struct
sockaddr
sa
;
char
host
[
INET6_ADDRSTRLEN
];
char
host
[
INET6_ADDRSTRLEN
];
int
port
,
rc
;
int
port
,
rc
;
std
::
stringstream
portnum
;
// Get the details of the TCP socket
// Get the details of the TCP socket
socklen_t
sl
=
sizeof
(
sockaddr
);
socklen_t
sl
=
sizeof
(
sockaddr
);
...
@@ -136,15 +138,17 @@ int zmq::tcp_listener_t::get_address (unsigned char *addr, size_t *len)
...
@@ -136,15 +138,17 @@ int zmq::tcp_listener_t::get_address (unsigned char *addr, size_t *len)
if
(
sa
.
sa_family
==
AF_INET
)
{
if
(
sa
.
sa_family
==
AF_INET
)
{
inet_ntop
(
AF_INET
,
&
(((
struct
sockaddr_in
*
)
&
sa
)
->
sin_addr
),
host
,
INET6_ADDRSTRLEN
);
inet_ntop
(
AF_INET
,
&
(((
struct
sockaddr_in
*
)
&
sa
)
->
sin_addr
),
host
,
INET6_ADDRSTRLEN
);
port
=
ntohs
(
((
struct
sockaddr_in
*
)
&
sa
)
->
sin_port
);
port
=
ntohs
(
((
struct
sockaddr_in
*
)
&
sa
)
->
sin_port
);
portnum
<<
port
;
// Store the address for retrieval by users using wildcards
// Store the address for retrieval by users using wildcards
*
len
=
sprintf
((
char
*
)
addr
,
"tcp://%s:%d"
,
host
,
port
);
*
addr_
=
std
::
string
(
"tcp://"
)
+
std
::
string
(
host
)
+
std
::
string
(
":"
)
+
portnum
.
str
(
);
}
else
{
}
else
{
inet_ntop
(
AF_INET6
,
&
(((
struct
sockaddr_in6
*
)
&
sa
)
->
sin6_addr
),
host
,
INET6_ADDRSTRLEN
);
inet_ntop
(
AF_INET6
,
&
(((
struct
sockaddr_in6
*
)
&
sa
)
->
sin6_addr
),
host
,
INET6_ADDRSTRLEN
);
port
=
ntohs
(
((
struct
sockaddr_in6
*
)
&
sa
)
->
sin6_port
);
port
=
ntohs
(
((
struct
sockaddr_in6
*
)
&
sa
)
->
sin6_port
);
portnum
<<
port
;
// Store the address for retrieval by users using wildcards
// Store the address for retrieval by users using wildcards
*
len
=
sprintf
((
char
*
)
*
addr
,
"tcp://[%s]:%d"
,
host
,
port
);
*
addr_
=
std
::
string
(
"tcp://["
)
+
std
::
string
(
host
)
+
std
::
string
(
"]:"
)
+
portnum
.
str
(
);
}
}
return
0
;
return
0
;
...
...
src/tcp_listener.hpp
View file @
b5d33739
...
@@ -46,7 +46,7 @@ namespace zmq
...
@@ -46,7 +46,7 @@ namespace zmq
int
set_address
(
const
char
*
addr_
);
int
set_address
(
const
char
*
addr_
);
// Get the bound address for use with wildcard
// Get the bound address for use with wildcard
int
get_address
(
unsigned
char
*
addr
,
size_t
*
len
);
int
get_address
(
std
::
string
*
addr_
);
private
:
private
:
...
...
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