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
34d65e22
Commit
34d65e22
authored
Jan 22, 2010
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tero Marttila's Ipv6 patch - part I.
parent
6edec4fe
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
31 deletions
+35
-31
fd_signaler.cpp
src/fd_signaler.cpp
+0
-1
ip.cpp
src/ip.cpp
+14
-10
ip.hpp
src/ip.hpp
+3
-3
tcp_connecter.cpp
src/tcp_connecter.cpp
+9
-8
tcp_connecter.hpp
src/tcp_connecter.hpp
+1
-1
tcp_listener.cpp
src/tcp_listener.cpp
+8
-8
No files found.
src/fd_signaler.cpp
View file @
34d65e22
...
...
@@ -127,7 +127,6 @@ zmq::fd_signaler_t::fd_signaler_t ()
memset
(
&
addr
,
0
,
sizeof
(
addr
));
addr
.
sin_family
=
AF_INET
;
//resolve_ip_hostname (&addr, "127.0.0.1:0");
addr
.
sin_addr
.
s_addr
=
htonl
(
INADDR_LOOPBACK
);
addr
.
sin_port
=
0
;
...
...
src/ip.cpp
View file @
34d65e22
...
...
@@ -245,8 +245,10 @@ static int resolve_nic_name (in_addr* addr_, char const *interface_)
#endif
int
zmq
::
resolve_ip_interface
(
sockaddr_
in
*
addr_
,
char
const
*
interface_
)
int
zmq
::
resolve_ip_interface
(
sockaddr_
storage
*
addr_
,
char
const
*
interface_
)
{
sockaddr_in
*
addr
=
(
sockaddr_in
*
)
addr_
;
// Find the ':' that separates NIC name from port.
const
char
*
delimiter
=
strchr
(
interface_
,
':'
);
if
(
!
delimiter
)
{
...
...
@@ -255,17 +257,17 @@ int zmq::resolve_ip_interface (sockaddr_in* addr_, char const *interface_)
}
// Clean the structure and fill in protocol family.
memset
(
addr
_
,
0
,
sizeof
(
sockaddr_in
));
addr
_
->
sin_family
=
AF_INET
;
memset
(
addr
,
0
,
sizeof
(
sockaddr_in
));
addr
->
sin_family
=
AF_INET
;
// Resolve the name of the NIC.
std
::
string
nic_name
(
interface_
,
delimiter
-
interface_
);
if
(
resolve_nic_name
(
&
addr
_
->
sin_addr
,
nic_name
.
c_str
())
!=
0
)
if
(
resolve_nic_name
(
&
addr
->
sin_addr
,
nic_name
.
c_str
())
!=
0
)
return
-
1
;
// Resolve the port.
addr
_
->
sin_port
=
htons
((
uint16_t
)
atoi
(
delimiter
+
1
));
if
(
!
addr
_
->
sin_port
)
{
addr
->
sin_port
=
htons
((
uint16_t
)
atoi
(
delimiter
+
1
));
if
(
!
addr
->
sin_port
)
{
errno
=
EINVAL
;
return
-
1
;
}
...
...
@@ -273,8 +275,10 @@ int zmq::resolve_ip_interface (sockaddr_in* addr_, char const *interface_)
return
0
;
}
int
zmq
::
resolve_ip_hostname
(
sockaddr_
in
*
addr_
,
const
char
*
hostname_
)
int
zmq
::
resolve_ip_hostname
(
sockaddr_
storage
*
addr_
,
const
char
*
hostname_
)
{
sockaddr_in
*
addr
=
(
sockaddr_in
*
)
addr_
;
// Find the ':' that separates hostname name from port.
const
char
*
delimiter
=
strchr
(
hostname_
,
':'
);
if
(
!
delimiter
)
{
...
...
@@ -297,12 +301,12 @@ int zmq::resolve_ip_hostname (sockaddr_in *addr_, const char *hostname_)
return
-
1
;
}
zmq_assert
(
res
->
ai_addr
->
sa_family
==
AF_INET
);
memcpy
(
addr
_
,
res
->
ai_addr
,
sizeof
(
sockaddr_in
));
memcpy
(
addr
,
res
->
ai_addr
,
sizeof
(
sockaddr_in
));
freeaddrinfo
(
res
);
// Fill in the port number.
addr
_
->
sin_port
=
htons
((
uint16_t
)
atoi
(
delimiter
+
1
));
if
(
!
addr
_
->
sin_port
)
{
addr
->
sin_port
=
htons
((
uint16_t
)
atoi
(
delimiter
+
1
));
if
(
!
addr
->
sin_port
)
{
errno
=
EINVAL
;
return
-
1
;
}
...
...
src/ip.hpp
View file @
34d65e22
...
...
@@ -41,15 +41,15 @@ namespace zmq
// Resolves network interface name in <nic-name>:<port> format. Symbol "*"
// (asterisk) resolves to INADDR_ANY (all network interfaces).
int
resolve_ip_interface
(
sockaddr_
in
*
addr_
,
char
const
*
interface_
);
int
resolve_ip_interface
(
sockaddr_
storage
*
addr_
,
char
const
*
interface_
);
// This function resolves a string in <hostname>:<port-number> format.
// Hostname can be either the name of the host or its IP address.
int
resolve_ip_hostname
(
sockaddr_
in
*
addr_
,
const
char
*
hostname_
);
int
resolve_ip_hostname
(
sockaddr_
storage
*
addr_
,
const
char
*
hostname_
);
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS
// This function sets up the sockaddr_un structure with the pathname_
int
resolve_local_path
(
sockaddr_un
*
addr_
,
const
char
*
pathname_
);
int
resolve_local_path
(
sockaddr_un
*
addr_
,
const
char
*
pathname_
);
#endif
}
...
...
src/tcp_connecter.cpp
View file @
34d65e22
...
...
@@ -45,7 +45,7 @@ zmq::tcp_connecter_t::~tcp_connecter_t ()
int
zmq
::
tcp_connecter_t
::
set_address
(
const
char
*
protocol_
,
const
char
*
addr_
)
{
if
(
strcmp
(
protocol_
,
"tcp"
)
==
0
)
return
resolve_ip_hostname
(
(
sockaddr_in
*
)
&
addr
,
addr_
);
return
resolve_ip_hostname
(
&
addr
,
addr_
);
errno
=
EPROTONOSUPPORT
;
return
-
1
;
...
...
@@ -56,7 +56,7 @@ int zmq::tcp_connecter_t::open ()
zmq_assert
(
s
==
retired_fd
);
// Create the socket.
s
=
socket
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
s
=
socket
(
addr
.
ss_family
,
SOCK_STREAM
,
IPPROTO_TCP
);
if
(
s
==
INVALID_SOCKET
)
{
wsa_error_to_errno
();
return
-
1
;
...
...
@@ -74,7 +74,7 @@ int zmq::tcp_connecter_t::open ()
wsa_assert
(
rc
!=
SOCKET_ERROR
);
// Connect to the remote peer.
rc
=
::
connect
(
s
,
(
sockaddr
*
)
&
addr
,
sizeof
(
sockaddr_in
));
rc
=
::
connect
(
s
,
(
sockaddr
*
)
&
addr
,
sizeof
(
addr
));
// Connect was successfull immediately.
if
(
rc
==
0
)
...
...
@@ -153,7 +153,7 @@ zmq::tcp_connecter_t::~tcp_connecter_t ()
int
zmq
::
tcp_connecter_t
::
set_address
(
const
char
*
protocol_
,
const
char
*
addr_
)
{
if
(
strcmp
(
protocol_
,
"tcp"
)
==
0
)
return
resolve_ip_hostname
(
(
struct
sockaddr_in
*
)
&
addr
,
addr_
);
return
resolve_ip_hostname
(
&
addr
,
addr_
);
else
if
(
strcmp
(
protocol_
,
"ipc"
)
==
0
)
return
resolve_local_path
((
struct
sockaddr_un
*
)
&
addr
,
addr_
);
...
...
@@ -166,10 +166,10 @@ int zmq::tcp_connecter_t::open ()
zmq_assert
(
s
==
retired_fd
);
struct
sockaddr
*
sa
=
(
struct
sockaddr
*
)
&
addr
;
if
(
AF_
INET
=
=
sa
->
sa_family
)
{
if
(
AF_
UNIX
!
=
sa
->
sa_family
)
{
// Create the socket.
s
=
socket
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
s
=
socket
(
sa
->
sa_family
,
SOCK_STREAM
,
IPPROTO_TCP
);
if
(
s
==
-
1
)
return
-
1
;
...
...
@@ -193,7 +193,7 @@ int zmq::tcp_connecter_t::open ()
#endif
// Connect to the remote peer.
rc
=
::
connect
(
s
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
sockaddr_in
));
rc
=
::
connect
(
s
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
));
// Connect was successfull immediately.
if
(
rc
==
0
)
...
...
@@ -211,9 +211,10 @@ int zmq::tcp_connecter_t::open ()
errno
=
err
;
return
-
1
;
}
else
if
(
AF_UNIX
==
sa
->
sa_family
)
{
else
{
// Create the socket.
zmq_assert
(
AF_UNIX
==
sa
->
sa_family
);
s
=
socket
(
AF_UNIX
,
SOCK_STREAM
,
0
);
if
(
s
==
-
1
)
return
-
1
;
...
...
src/tcp_connecter.hpp
View file @
34d65e22
...
...
@@ -58,7 +58,7 @@ namespace zmq
private
:
// Address to connect to.
sockaddr_
in
addr
;
sockaddr_
storage
addr
;
// Underlying socket.
fd_t
s
;
...
...
src/tcp_listener.cpp
View file @
34d65e22
...
...
@@ -50,12 +50,12 @@ int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_)
}
// Convert the interface into sockaddr_in structure.
int
rc
=
resolve_ip_interface
(
(
sockaddr_in
*
)
&
addr
,
addr_
);
int
rc
=
resolve_ip_interface
(
&
addr
,
addr_
);
if
(
rc
!=
0
)
return
rc
;
// Create a listening socket.
s
=
socket
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
s
=
socket
(
addr
.
ss_family
,
SOCK_STREAM
,
IPPROTO_TCP
);
if
(
s
==
INVALID_SOCKET
)
{
wsa_error_to_errno
();
return
-
1
;
...
...
@@ -73,7 +73,7 @@ int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_)
wsa_assert
(
rc
!=
SOCKET_ERROR
);
// Bind the socket to the network interface and port.
rc
=
bind
(
s
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
sockaddr_in
));
rc
=
bind
(
s
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
));
if
(
rc
==
SOCKET_ERROR
)
{
wsa_error_to_errno
();
return
-
1
;
...
...
@@ -157,13 +157,13 @@ int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_)
{
if
(
strcmp
(
protocol_
,
"tcp"
)
==
0
)
{
//
Convert the interface into sockaddr_in structure
.
int
rc
=
resolve_ip_interface
(
(
struct
sockaddr_in
*
)
&
addr
,
addr_
);
//
Resolve the sockaddr to bind to
.
int
rc
=
resolve_ip_interface
(
&
addr
,
addr_
);
if
(
rc
!=
0
)
return
-
1
;
// Create a listening socket.
s
=
socket
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
s
=
socket
(
addr
.
ss_family
,
SOCK_STREAM
,
IPPROTO_TCP
);
if
(
s
==
-
1
)
return
-
1
;
...
...
@@ -180,7 +180,7 @@ int zmq::tcp_listener_t::set_address (const char *protocol_, const char *addr_)
errno_assert
(
rc
!=
-
1
);
// Bind the socket to the network interface and port.
rc
=
bind
(
s
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
sockaddr_in
));
rc
=
bind
(
s
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
));
if
(
rc
!=
0
)
{
close
();
return
-
1
;
...
...
@@ -305,7 +305,7 @@ zmq::fd_t zmq::tcp_listener_t::accept ()
errno_assert
(
rc
!=
-
1
);
struct
sockaddr
*
sa
=
(
struct
sockaddr
*
)
&
addr
;
if
(
AF_
INET
=
=
sa
->
sa_family
)
{
if
(
AF_
UNIX
!
=
sa
->
sa_family
)
{
// Disable Nagle's algorithm.
int
flag
=
1
;
...
...
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