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
49a9ef5f
Commit
49a9ef5f
authored
Oct 01, 2009
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
windows error handling improved
parent
cc631c4c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
12 deletions
+79
-12
zmq.h
bindings/c/zmq.h
+12
-0
err.cpp
src/err.cpp
+41
-2
err.hpp
src/err.hpp
+1
-0
tcp_connecter.cpp
src/tcp_connecter.cpp
+5
-5
tcp_listener.cpp
src/tcp_listener.cpp
+12
-5
zmq.cpp
src/zmq.cpp
+8
-0
No files found.
bindings/c/zmq.h
View file @
49a9ef5f
...
@@ -51,6 +51,18 @@ extern "C" {
...
@@ -51,6 +51,18 @@ extern "C" {
#ifndef EPROTONOSUPPORT
#ifndef EPROTONOSUPPORT
#define EPROTONOSUPPORT (ZMQ_HAUSNUMERO + 2)
#define EPROTONOSUPPORT (ZMQ_HAUSNUMERO + 2)
#endif
#endif
#ifndef ENOBUFS
#define ENOBUFS (ZMQ_HAUSNUMERO + 3)
#endif
#ifndef ENETDOWN
#define ENETDOWN (ZMQ_HAUSNUMERO + 4)
#endif
#ifndef EADDRINUSE
#define EADDRINUSE (ZMQ_HAUSNUMERO + 5)
#endif
#ifndef EADDRNOTAVAIL
#define EADDRNOTAVAIL (ZMQ_HAUSNUMERO + 6)
#endif
// Native 0MQ error codes.
// Native 0MQ error codes.
#define EMTHREAD (ZMQ_HAUSNUMERO + 50)
#define EMTHREAD (ZMQ_HAUSNUMERO + 50)
...
...
src/err.cpp
View file @
49a9ef5f
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "../bindings/c/zmq.h"
#include "err.hpp"
#include "err.hpp"
#include "platform.hpp"
#include "platform.hpp"
...
@@ -24,8 +26,6 @@
...
@@ -24,8 +26,6 @@
const
char
*
zmq
::
wsa_error
()
const
char
*
zmq
::
wsa_error
()
{
{
int
errcode
=
WSAGetLastError
();
int
errcode
=
WSAGetLastError
();
// TODO: This is not a generic way to handle this...
// TODO: This is not a generic way to handle this...
if
(
errcode
==
WSAEWOULDBLOCK
)
if
(
errcode
==
WSAEWOULDBLOCK
)
...
@@ -148,4 +148,43 @@ void zmq::win_error (char *buffer_, size_t buffer_size_)
...
@@ -148,4 +148,43 @@ void zmq::win_error (char *buffer_, size_t buffer_size_)
zmq_assert
(
rc
);
zmq_assert
(
rc
);
}
}
void
zmq
::
wsa_error_to_errno
()
{
int
errcode
=
WSAGetLastError
();
switch
(
errcode
)
{
case
WSAEINPROGRESS
:
errno
=
EAGAIN
;
return
;
case
WSAEBADF
:
errno
=
EBADF
;
return
;
case
WSAEINVAL
:
errno
=
EINVAL
;
return
;
case
WSAEMFILE
:
errno
=
EMFILE
;
return
;
case
WSAEFAULT
:
errno
=
EFAULT
;
return
;
case
WSAEPROTONOSUPPORT
:
errno
=
EPROTONOSUPPORT
;
return
;
case
WSAENOBUFS
:
errno
=
ENOBUFS
;
return
;
case
WSAENETDOWN
:
errno
=
ENETDOWN
;
return
;
case
WSAEADDRINUSE
:
errno
=
EADDRINUSE
;
return
;
case
WSAEADDRNOTAVAIL
:
errno
=
EADDRNOTAVAIL
;
return
;
default
:
wsa_assert
(
false
);
}
}
#endif
#endif
src/err.hpp
View file @
49a9ef5f
...
@@ -41,6 +41,7 @@ namespace zmq
...
@@ -41,6 +41,7 @@ namespace zmq
const
char
*
wsa_error
();
const
char
*
wsa_error
();
void
win_error
(
char
*
buffer_
,
size_t
buffer_size_
);
void
win_error
(
char
*
buffer_
,
size_t
buffer_size_
);
void
wsa_error_to_errno
();
}
}
...
...
src/tcp_connecter.cpp
View file @
49a9ef5f
...
@@ -50,8 +50,10 @@ int zmq::tcp_connecter_t::open ()
...
@@ -50,8 +50,10 @@ int zmq::tcp_connecter_t::open ()
// Create the socket.
// Create the socket.
s
=
socket
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
s
=
socket
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
// TODO: Convert error to errno.
if
(
s
==
INVALID_SOCKET
)
{
wsa_assert
(
s
!=
INVALID_SOCKET
);
wsa_error_to_errno
();
return
-
1
;
}
// Set to non-blocking mode.
// Set to non-blocking mode.
unsigned
long
argp
=
1
;
unsigned
long
argp
=
1
;
...
@@ -78,9 +80,7 @@ int zmq::tcp_connecter_t::open ()
...
@@ -78,9 +80,7 @@ int zmq::tcp_connecter_t::open ()
return
-
1
;
return
-
1
;
}
}
// TODO: Convert error to errno.
wsa_error_to_errno
();
wsa_assert
(
rc
==
0
);
return
-
1
;
return
-
1
;
}
}
...
...
src/tcp_listener.cpp
View file @
49a9ef5f
...
@@ -48,8 +48,10 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
...
@@ -48,8 +48,10 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
// Create a listening socket.
// Create a listening socket.
s
=
socket
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
s
=
socket
(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
// TODO: Convert error code to errno.
if
(
s
==
INVALID_SOCKET
)
{
wsa_assert
(
s
!=
INVALID_SOCKET
);
wsa_error_to_errno
();
return
-
1
;
}
// Allow reusing of the address.
// Allow reusing of the address.
int
flag
=
1
;
int
flag
=
1
;
...
@@ -65,12 +67,17 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
...
@@ -65,12 +67,17 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
// Bind the socket to the network interface and port.
// Bind the socket to the network interface and port.
rc
=
bind
(
s
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
));
rc
=
bind
(
s
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
));
// TODO: Convert error code to errno.
// TODO: Convert error code to errno.
wsa_assert
(
rc
!=
SOCKET_ERROR
);
if
(
rc
==
SOCKET_ERROR
)
{
wsa_error_to_errno
();
return
-
1
;
}
// Listen for incomming connections.
// Listen for incomming connections.
rc
=
listen
(
s
,
1
);
rc
=
listen
(
s
,
1
);
// TODO: Convert error code to errno.
if
(
rc
==
SOCKET_ERROR
)
{
wsa_assert
(
rc
!=
SOCKET_ERROR
);
wsa_error_to_errno
();
return
-
1
;
}
return
0
;
return
0
;
}
}
...
...
src/zmq.cpp
View file @
49a9ef5f
...
@@ -49,6 +49,14 @@ const char *zmq_strerror (int errnum_)
...
@@ -49,6 +49,14 @@ const char *zmq_strerror (int errnum_)
return
"Not supported"
;
return
"Not supported"
;
case
EPROTONOSUPPORT
:
case
EPROTONOSUPPORT
:
return
"Protocol not supported"
;
return
"Protocol not supported"
;
case
ENOBUFS
:
return
"No buffer space available"
;
case
ENETDOWN
:
return
"Network is down"
;
case
EADDRINUSE
:
return
"Address in use"
;
case
EADDRNOTAVAIL
:
return
"Address not available"
;
#endif
#endif
case
EMTHREAD
:
case
EMTHREAD
:
return
"Number of preallocated application threads exceeded"
;
return
"Number of preallocated application threads exceeded"
;
...
...
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