fixes #842 Managing sock types in a list is silly
fixes #841 Common code (global, etc) should not get protocol internals
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3e148b4..e1aa679 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -127,28 +127,22 @@
     protocols/utils/priolist.h
     protocols/utils/priolist.c
 
-    protocols/bus/bus.h
     protocols/bus/bus.c
     protocols/bus/xbus.h
     protocols/bus/xbus.c
 
-    protocols/pipeline/push.h
     protocols/pipeline/push.c
-    protocols/pipeline/pull.h
     protocols/pipeline/pull.c
     protocols/pipeline/xpull.h
     protocols/pipeline/xpull.c
     protocols/pipeline/xpush.h
     protocols/pipeline/xpush.c
 
-    protocols/pair/pair.h
     protocols/pair/pair.c
     protocols/pair/xpair.h
     protocols/pair/xpair.c
 
-    protocols/pubsub/pub.h
     protocols/pubsub/pub.c
-    protocols/pubsub/sub.h
     protocols/pubsub/sub.c
     protocols/pubsub/trie.h
     protocols/pubsub/trie.c
@@ -168,9 +162,7 @@
     protocols/reqrep/xreq.h
     protocols/reqrep/xreq.c
 
-    protocols/survey/respondent.h
     protocols/survey/respondent.c
-    protocols/survey/surveyor.h
     protocols/survey/surveyor.c
     protocols/survey/xrespondent.h
     protocols/survey/xrespondent.c
diff --git a/src/core/global.c b/src/core/global.c
index 20dce1c..fa01418 100644
--- a/src/core/global.c
+++ b/src/core/global.c
@@ -50,27 +50,6 @@
 #include "../transports/tcp/tcp.h"
 #include "../transports/ws/ws.h"
 
-#include "../protocols/pair/pair.h"
-#include "../protocols/pair/xpair.h"
-#include "../protocols/pubsub/pub.h"
-#include "../protocols/pubsub/sub.h"
-#include "../protocols/pubsub/xpub.h"
-#include "../protocols/pubsub/xsub.h"
-#include "../protocols/reqrep/rep.h"
-#include "../protocols/reqrep/req.h"
-#include "../protocols/reqrep/xrep.h"
-#include "../protocols/reqrep/xreq.h"
-#include "../protocols/pipeline/push.h"
-#include "../protocols/pipeline/pull.h"
-#include "../protocols/pipeline/xpush.h"
-#include "../protocols/pipeline/xpull.h"
-#include "../protocols/survey/respondent.h"
-#include "../protocols/survey/surveyor.h"
-#include "../protocols/survey/xrespondent.h"
-#include "../protocols/survey/xsurveyor.h"
-#include "../protocols/bus/bus.h"
-#include "../protocols/bus/xbus.h"
-
 #include "../pubsub.h"
 #include "../pipeline.h"
 
@@ -103,6 +82,54 @@
 #define NN_GLOBAL_STATE_ACTIVE         2
 #define NN_GLOBAL_STATE_STOPPING_TIMER 3
 
+/*  We could put these in an external header file, but there really is
+    need to.  We are the only thing that needs them. */
+extern struct nn_socktype nn_pair_socktype;
+extern struct nn_socktype nn_xpair_socktype;
+extern struct nn_socktype nn_pub_socktype;
+extern struct nn_socktype nn_sub_socktype;
+extern struct nn_socktype nn_xpub_socktype;
+extern struct nn_socktype nn_xsub_socktype;
+extern struct nn_socktype nn_rep_socktype;
+extern struct nn_socktype nn_req_socktype;
+extern struct nn_socktype nn_xrep_socktype;
+extern struct nn_socktype nn_xreq_socktype;
+extern struct nn_socktype nn_push_socktype;
+extern struct nn_socktype nn_xpush_socktype;
+extern struct nn_socktype nn_pull_socktype;
+extern struct nn_socktype nn_xpull_socktype;
+extern struct nn_socktype nn_respondent_socktype;
+extern struct nn_socktype nn_surveyor_socktype;
+extern struct nn_socktype nn_xrespondent_socktype;
+extern struct nn_socktype nn_xsurveyor_socktype;
+extern struct nn_socktype nn_bus_socktype;
+extern struct nn_socktype nn_xbus_socktype;
+
+/*  Array of known socket types. */
+const struct nn_socktype *nn_socktypes[] = {
+    &nn_pair_socktype,
+    &nn_xpair_socktype,
+    &nn_pub_socktype,
+    &nn_sub_socktype,
+    &nn_xpub_socktype,
+    &nn_xsub_socktype,
+    &nn_rep_socktype,
+    &nn_req_socktype,
+    &nn_xrep_socktype,
+    &nn_xreq_socktype,
+    &nn_push_socktype,
+    &nn_xpush_socktype,
+    &nn_pull_socktype,
+    &nn_xpull_socktype,
+    &nn_respondent_socktype,
+    &nn_surveyor_socktype,
+    &nn_xrespondent_socktype,
+    &nn_xsurveyor_socktype,
+    &nn_bus_socktype,
+    &nn_xbus_socktype,
+    NULL,
+};
+
 struct nn_global {
 
     /*  The global table of existing sockets. The descriptor representing
@@ -125,9 +152,6 @@
         is never modified. */
     struct nn_list transports;
 
-    /*  List of all available socket types.  Again this list is not dynamic.*/
-    struct nn_list socktypes;
-
     /*  Pool of worker threads. */
     struct nn_pool pool;
 
@@ -151,7 +175,6 @@
 
 /*  Transport-related private functions. */
 static void nn_global_add_transport (struct nn_transport *transport);
-static void nn_global_add_socktype (struct nn_socktype *socktype);
 
 /*  Private function that unifies nn_bind and nn_connect functionality.
     It returns the ID of the newly created endpoint. */
@@ -226,7 +249,6 @@
 
     /*  Initialise other parts of the global state. */
     nn_list_init (&self.transports);
-    nn_list_init (&self.socktypes);
 
     /*  Plug in individual transports. */
     nn_global_add_transport (nn_inproc);
@@ -234,28 +256,6 @@
     nn_global_add_transport (nn_tcp);
     nn_global_add_transport (nn_ws);
 
-    /*  Plug in individual socktypes. */
-    nn_global_add_socktype (nn_pair_socktype);
-    nn_global_add_socktype (nn_xpair_socktype);
-    nn_global_add_socktype (nn_pub_socktype);
-    nn_global_add_socktype (nn_sub_socktype);
-    nn_global_add_socktype (nn_xpub_socktype);
-    nn_global_add_socktype (nn_xsub_socktype);
-    nn_global_add_socktype (nn_rep_socktype);
-    nn_global_add_socktype (nn_req_socktype);
-    nn_global_add_socktype (nn_xrep_socktype);
-    nn_global_add_socktype (nn_xreq_socktype);
-    nn_global_add_socktype (nn_push_socktype);
-    nn_global_add_socktype (nn_xpush_socktype);
-    nn_global_add_socktype (nn_pull_socktype);
-    nn_global_add_socktype (nn_xpull_socktype);
-    nn_global_add_socktype (nn_respondent_socktype);
-    nn_global_add_socktype (nn_surveyor_socktype);
-    nn_global_add_socktype (nn_xrespondent_socktype);
-    nn_global_add_socktype (nn_xsurveyor_socktype);
-    nn_global_add_socktype (nn_bus_socktype);
-    nn_global_add_socktype (nn_xbus_socktype);
-
     /*  Start the worker threads. */
     nn_pool_init (&self.pool);
 }
@@ -285,13 +285,7 @@
         nn_list_erase (&self.transports, it);
     }
 
-    /*  For now there's nothing to deallocate about socket types, however,
-        let's remove them from the list anyway. */
-    while (!nn_list_empty (&self.socktypes))
-        nn_list_erase (&self.socktypes, nn_list_begin (&self.socktypes));
-
     /*  Final deallocation of the nn_global object itself. */
-    nn_list_term (&self.socktypes);
     nn_list_term (&self.transports);
     nn_free (self.socks);
 
@@ -418,19 +412,20 @@
 {
     int rc;
     int s;
+    int i;
     struct nn_list_item *it;
-    struct nn_socktype *socktype;
+    const struct nn_socktype *socktype;
     struct nn_sock *sock;
 
     /* The function is called with lock held */
 
     /*  Only AF_SP and AF_SP_RAW domains are supported. */
-    if (nn_slow (domain != AF_SP && domain != AF_SP_RAW)) {
+    if (domain != AF_SP && domain != AF_SP_RAW) {
         return -EAFNOSUPPORT;
     }
 
     /*  If socket limit was reached, report error. */
-    if (nn_slow (self.nsocks >= NN_MAX_SOCKETS)) {
+    if (self.nsocks >= NN_MAX_SOCKETS) {
         return -EMFILE;
     }
 
@@ -438,15 +433,12 @@
     s = self.unused [NN_MAX_SOCKETS - self.nsocks - 1];
 
     /*  Find the appropriate socket type. */
-    for (it = nn_list_begin (&self.socktypes);
-          it != nn_list_end (&self.socktypes);
-          it = nn_list_next (&self.socktypes, it)) {
-        socktype = nn_cont (it, struct nn_socktype, item);
+    for (i = 0; (socktype = nn_socktypes[i]) != NULL; i++) {
         if (socktype->domain == domain && socktype->protocol == protocol) {
 
             /*  Instantiate the socket. */
-            sock = nn_alloc (sizeof (struct nn_sock), "sock");
-            alloc_assert (sock);
+            if ((sock = nn_alloc (sizeof (struct nn_sock), "sock")) == NULL)
+                return -ENOMEM;
             rc = nn_sock_init (sock, socktype, s);
             if (rc < 0)
                 return rc;
@@ -1059,12 +1051,6 @@
         nn_list_end (&self.transports));
 }
 
-static void nn_global_add_socktype (struct nn_socktype *socktype)
-{
-    nn_list_insert (&self.socktypes, &socktype->item,
-        nn_list_end (&self.socktypes));
-}
-
 static int nn_global_create_ep (struct nn_sock *sock, const char *addr,
     int bind)
 {
diff --git a/src/core/sock.c b/src/core/sock.c
index 17f9c6e..e850ba3 100644
--- a/src/core/sock.c
+++ b/src/core/sock.c
@@ -69,7 +69,8 @@
 
 /*  Initialize a socket.  A hold is placed on the initialized socket for
     the caller as well. */
-int nn_sock_init (struct nn_sock *self, struct nn_socktype *socktype, int fd)
+int nn_sock_init (struct nn_sock *self, const struct nn_socktype *socktype,
+    int fd)
 {
     int rc;
     int i;
diff --git a/src/core/sock.h b/src/core/sock.h
index 6680674..584bcbe 100644
--- a/src/core/sock.h
+++ b/src/core/sock.h
@@ -49,7 +49,7 @@
     struct nn_sockbase *sockbase;
 
     /*  Pointer to the socket type metadata. */
-    struct nn_socktype *socktype;
+    const struct nn_socktype *socktype;
 
     int flags;
 
@@ -140,7 +140,8 @@
 };
 
 /*  Initialise the socket. */
-int nn_sock_init (struct nn_sock *self, struct nn_socktype *socktype, int fd);
+int nn_sock_init (struct nn_sock *self, const struct nn_socktype *socktype,
+    int fd);
 
 /*  Called by nn_close() to stop activity on the socket.  It doesn't block. */
 void nn_sock_stop (struct nn_sock *self);
diff --git a/src/protocol.h b/src/protocol.h
index 476185f..1d0ae02 100644
--- a/src/protocol.h
+++ b/src/protocol.h
@@ -187,10 +187,6 @@
         SP protocol. Peers speaking other SP protocols are discarded by the
         core and socket is not even asked to validate them. */
     int (*ispeer) (int socktype);
-
-    /*  This member is owned by the core. Never touch it directly from inside
-        the protocol implementation. */
-    struct nn_list_item item;
 };
 
 #endif
diff --git a/src/protocols/bus/bus.c b/src/protocols/bus/bus.c
index 3064fa8..db3e847 100644
--- a/src/protocols/bus/bus.c
+++ b/src/protocols/bus/bus.c
@@ -20,7 +20,6 @@
     IN THE SOFTWARE.
 */
 
-#include "bus.h"
 #include "xbus.h"
 
 #include "../../nn.h"
@@ -29,7 +28,6 @@
 #include "../../utils/cont.h"
 #include "../../utils/alloc.h"
 #include "../../utils/err.h"
-#include "../../utils/list.h"
 
 struct nn_bus {
     struct nn_xbus xbus;
@@ -130,14 +128,10 @@
     return 0;
 }
 
-static struct nn_socktype nn_bus_socktype_struct = {
+struct nn_socktype nn_bus_socktype = {
     AF_SP,
     NN_BUS,
     0,
     nn_bus_create,
     nn_xbus_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_bus_socktype = &nn_bus_socktype_struct;
-
diff --git a/src/protocols/bus/bus.h b/src/protocols/bus/bus.h
deleted file mode 100644
index 4390ace..0000000
--- a/src/protocols/bus/bus.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-    Copyright (c) 2013 Martin Sustrik  All rights reserved.
-
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"),
-    to deal in the Software without restriction, including without limitation
-    the rights to use, copy, modify, merge, publish, distribute, sublicense,
-    and/or sell copies of the Software, and to permit persons to whom
-    the Software is furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be included
-    in all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-    IN THE SOFTWARE.
-*/
-
-#ifndef NN_BUS_INCLUDED
-#define NN_BUS_INCLUDED
-
-#include "../../protocol.h"
-
-extern struct nn_socktype *nn_bus_socktype;
-
-#endif
diff --git a/src/protocols/bus/xbus.c b/src/protocols/bus/xbus.c
index 50e89e9..ac33995 100644
--- a/src/protocols/bus/xbus.c
+++ b/src/protocols/bus/xbus.c
@@ -227,14 +227,10 @@
     return socktype == NN_BUS ? 1 : 0;
 }
 
-static struct nn_socktype nn_xbus_socktype_struct = {
+struct nn_socktype nn_xbus_socktype = {
     AF_SP_RAW,
     NN_BUS,
     0,
     nn_xbus_create,
     nn_xbus_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_xbus_socktype = &nn_xbus_socktype_struct;
-
diff --git a/src/protocols/bus/xbus.h b/src/protocols/bus/xbus.h
index bdf04f8..e0a439c 100644
--- a/src/protocols/bus/xbus.h
+++ b/src/protocols/bus/xbus.h
@@ -28,8 +28,6 @@
 #include "../utils/dist.h"
 #include "../utils/fq.h"
 
-extern struct nn_socktype *nn_xbus_socktype;
-
 struct nn_xbus_data {
     struct nn_dist_data outitem;
     struct nn_fq_data initem;
diff --git a/src/protocols/pair/pair.c b/src/protocols/pair/pair.c
index 4cbb3fb..014abeb 100644
--- a/src/protocols/pair/pair.c
+++ b/src/protocols/pair/pair.c
@@ -20,21 +20,15 @@
     IN THE SOFTWARE.
 */
 
-#include "pair.h"
 #include "xpair.h"
 
 #include "../../nn.h"
 #include "../../pair.h"
-#include "../../utils/list.h"
 
-static struct nn_socktype nn_pair_socktype_struct = {
+struct nn_socktype nn_pair_socktype = {
     AF_SP,
     NN_PAIR,
     0,
     nn_xpair_create,
     nn_xpair_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_pair_socktype = &nn_pair_socktype_struct;
-
diff --git a/src/protocols/pair/pair.h b/src/protocols/pair/pair.h
deleted file mode 100644
index b33ab48..0000000
--- a/src/protocols/pair/pair.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-    Copyright (c) 2012-2013 Martin Sustrik  All rights reserved.
-
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"),
-    to deal in the Software without restriction, including without limitation
-    the rights to use, copy, modify, merge, publish, distribute, sublicense,
-    and/or sell copies of the Software, and to permit persons to whom
-    the Software is furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be included
-    in all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-    IN THE SOFTWARE.
-*/
-
-#ifndef NN_PAIR_INCLUDED
-#define NN_PAIR_INCLUDED
-
-#include "../../protocol.h"
-
-extern struct nn_socktype *nn_pair_socktype;
-
-#endif
diff --git a/src/protocols/pair/xpair.c b/src/protocols/pair/xpair.c
index ab925a1..6364197 100644
--- a/src/protocols/pair/xpair.c
+++ b/src/protocols/pair/xpair.c
@@ -29,9 +29,7 @@
 
 #include "../../utils/err.h"
 #include "../../utils/cont.h"
-#include "../../utils/fast.h"
 #include "../../utils/alloc.h"
-#include "../../utils/list.h"
 #include "../../utils/attr.h"
 
 struct nn_xpair {
@@ -177,14 +175,10 @@
     return socktype == NN_PAIR ? 1 : 0;
 }
 
-static struct nn_socktype nn_xpair_socktype_struct = {
+struct nn_socktype nn_xpair_socktype = {
     AF_SP_RAW,
     NN_PAIR,
     0,
     nn_xpair_create,
     nn_xpair_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_xpair_socktype = &nn_xpair_socktype_struct;
-
diff --git a/src/protocols/pair/xpair.h b/src/protocols/pair/xpair.h
index a0738b3..518d8ac 100644
--- a/src/protocols/pair/xpair.h
+++ b/src/protocols/pair/xpair.h
@@ -25,8 +25,6 @@
 
 #include "../../protocol.h"
 
-extern struct nn_socktype *nn_xpair_socktype;
-
 int nn_xpair_create (void *hint, struct nn_sockbase **sockbase);
 int nn_xpair_ispeer (int socktype);
 
diff --git a/src/protocols/pipeline/pull.c b/src/protocols/pipeline/pull.c
index ec9f1d6..2e4f142 100644
--- a/src/protocols/pipeline/pull.c
+++ b/src/protocols/pipeline/pull.c
@@ -20,21 +20,15 @@
     IN THE SOFTWARE.
 */
 
-#include "pull.h"
 #include "xpull.h"
 
 #include "../../nn.h"
 #include "../../pipeline.h"
-#include "../../utils/list.h"
 
-static struct nn_socktype nn_pull_socktype_struct = {
+struct nn_socktype nn_pull_socktype = {
     AF_SP,
     NN_PULL,
     NN_SOCKTYPE_FLAG_NOSEND,
     nn_xpull_create,
     nn_xpull_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_pull_socktype = &nn_pull_socktype_struct;
-
diff --git a/src/protocols/pipeline/pull.h b/src/protocols/pipeline/pull.h
deleted file mode 100644
index 592e6cf..0000000
--- a/src/protocols/pipeline/pull.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-    Copyright (c) 2012-2013 Martin Sustrik  All rights reserved.
-
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"),
-    to deal in the Software without restriction, including without limitation
-    the rights to use, copy, modify, merge, publish, distribute, sublicense,
-    and/or sell copies of the Software, and to permit persons to whom
-    the Software is furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be included
-    in all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-    IN THE SOFTWARE.
-*/
-
-#ifndef NN_PULL_INCLUDED
-#define NN_PULL_INCLUDED
-
-#include "../../protocol.h"
-
-extern struct nn_socktype *nn_pull_socktype;
-
-#endif
diff --git a/src/protocols/pipeline/push.c b/src/protocols/pipeline/push.c
index 061f07e..77cd671 100644
--- a/src/protocols/pipeline/push.c
+++ b/src/protocols/pipeline/push.c
@@ -20,21 +20,15 @@
     IN THE SOFTWARE.
 */
 
-#include "push.h"
 #include "xpush.h"
 
 #include "../../nn.h"
 #include "../../pipeline.h"
-#include "../../utils/list.h"
 
-static struct nn_socktype nn_push_socktype_struct = {
+struct nn_socktype nn_push_socktype = {
     AF_SP,
     NN_PUSH,
     NN_SOCKTYPE_FLAG_NORECV,
     nn_xpush_create,
     nn_xpush_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_push_socktype = &nn_push_socktype_struct;
-
diff --git a/src/protocols/pipeline/push.h b/src/protocols/pipeline/push.h
deleted file mode 100644
index e0bb6a5..0000000
--- a/src/protocols/pipeline/push.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-    Copyright (c) 2012-2013 Martin Sustrik  All rights reserved.
-
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"),
-    to deal in the Software without restriction, including without limitation
-    the rights to use, copy, modify, merge, publish, distribute, sublicense,
-    and/or sell copies of the Software, and to permit persons to whom
-    the Software is furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be included
-    in all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-    IN THE SOFTWARE.
-*/
-
-#ifndef NN_PUSH_INCLUDED
-#define NN_PUSH_INCLUDED
-
-#include "../../protocol.h"
-
-extern struct nn_socktype *nn_push_socktype;
-
-#endif
-
diff --git a/src/protocols/pipeline/xpull.c b/src/protocols/pipeline/xpull.c
index 673accd..d2fada9 100644
--- a/src/protocols/pipeline/xpull.c
+++ b/src/protocols/pipeline/xpull.c
@@ -32,7 +32,6 @@
 #include "../../utils/cont.h"
 #include "../../utils/fast.h"
 #include "../../utils/alloc.h"
-#include "../../utils/list.h"
 #include "../../utils/attr.h"
 
 struct nn_xpull_data {
@@ -197,14 +196,10 @@
     return socktype == NN_PUSH ? 1 : 0;
 }
 
-static struct nn_socktype nn_xpull_socktype_struct = {
+struct nn_socktype nn_xpull_socktype = {
     AF_SP_RAW,
     NN_PULL,
     NN_SOCKTYPE_FLAG_NOSEND,
     nn_xpull_create,
     nn_xpull_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_xpull_socktype = &nn_xpull_socktype_struct;
-
diff --git a/src/protocols/pipeline/xpull.h b/src/protocols/pipeline/xpull.h
index 37ef9a4..24b79e3 100644
--- a/src/protocols/pipeline/xpull.h
+++ b/src/protocols/pipeline/xpull.h
@@ -25,8 +25,6 @@
 
 #include "../../protocol.h"
 
-extern struct nn_socktype *nn_xpull_socktype;
-
 int nn_xpull_create (void *hint, struct nn_sockbase **sockbase);
 int nn_xpull_ispeer (int socktype);
 
diff --git a/src/protocols/pipeline/xpush.c b/src/protocols/pipeline/xpush.c
index 2d938bd..4d09595 100644
--- a/src/protocols/pipeline/xpush.c
+++ b/src/protocols/pipeline/xpush.c
@@ -31,7 +31,6 @@
 #include "../../utils/cont.h"
 #include "../../utils/fast.h"
 #include "../../utils/alloc.h"
-#include "../../utils/list.h"
 #include "../../utils/attr.h"
 
 struct nn_xpush_data {
@@ -195,14 +194,10 @@
     return socktype == NN_PULL ? 1 : 0;
 }
 
-static struct nn_socktype nn_xpush_socktype_struct = {
+struct nn_socktype nn_xpush_socktype = {
     AF_SP_RAW,
     NN_PUSH,
     NN_SOCKTYPE_FLAG_NORECV,
     nn_xpush_create,
     nn_xpush_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_xpush_socktype = &nn_xpush_socktype_struct;
-
diff --git a/src/protocols/pipeline/xpush.h b/src/protocols/pipeline/xpush.h
index f7c7e60..14ae78c 100644
--- a/src/protocols/pipeline/xpush.h
+++ b/src/protocols/pipeline/xpush.h
@@ -25,8 +25,6 @@
 
 #include "../../protocol.h"
 
-extern struct nn_socktype *nn_xpush_socktype;
-
 int nn_xpush_create (void *hint, struct nn_sockbase **sockbase);
 int nn_xpush_ispeer (int socktype);
 
diff --git a/src/protocols/pubsub/pub.c b/src/protocols/pubsub/pub.c
index 44f9899..0a92281 100644
--- a/src/protocols/pubsub/pub.c
+++ b/src/protocols/pubsub/pub.c
@@ -20,21 +20,15 @@
     IN THE SOFTWARE.
 */
 
-#include "pub.h"
 #include "xpub.h"
 
 #include "../../nn.h"
 #include "../../pubsub.h"
-#include "../../utils/list.h"
 
-static struct nn_socktype nn_pub_socktype_struct = {
+struct nn_socktype nn_pub_socktype = {
     AF_SP,
     NN_PUB,
     NN_SOCKTYPE_FLAG_NORECV,
     nn_xpub_create,
     nn_xpub_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_pub_socktype = &nn_pub_socktype_struct;
-
diff --git a/src/protocols/pubsub/pub.h b/src/protocols/pubsub/pub.h
deleted file mode 100644
index 366ada8..0000000
--- a/src/protocols/pubsub/pub.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-    Copyright (c) 2013 Martin Sustrik  All rights reserved.
-
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"),
-    to deal in the Software without restriction, including without limitation
-    the rights to use, copy, modify, merge, publish, distribute, sublicense,
-    and/or sell copies of the Software, and to permit persons to whom
-    the Software is furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be included
-    in all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-    IN THE SOFTWARE.
-*/
-
-#ifndef NN_PUB_INCLUDED
-#define NN_PUB_INCLUDED
-
-#include "../../protocol.h"
-
-extern struct nn_socktype *nn_pub_socktype;
-
-#endif
diff --git a/src/protocols/pubsub/sub.c b/src/protocols/pubsub/sub.c
index 789dc76..21ea3d5 100644
--- a/src/protocols/pubsub/sub.c
+++ b/src/protocols/pubsub/sub.c
@@ -20,21 +20,15 @@
     IN THE SOFTWARE.
 */
 
-#include "sub.h"
 #include "xsub.h"
 
 #include "../../nn.h"
 #include "../../pubsub.h"
-#include "../../utils/list.h"
 
-static struct nn_socktype nn_sub_socktype_struct = {
+struct nn_socktype nn_sub_socktype = {
     AF_SP,
     NN_SUB,
     NN_SOCKTYPE_FLAG_NOSEND,
     nn_xsub_create,
     nn_xsub_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_sub_socktype = &nn_sub_socktype_struct;
-
diff --git a/src/protocols/pubsub/sub.h b/src/protocols/pubsub/sub.h
deleted file mode 100644
index 300c0ab..0000000
--- a/src/protocols/pubsub/sub.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-    Copyright (c) 2013 Martin Sustrik  All rights reserved.
-
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"),
-    to deal in the Software without restriction, including without limitation
-    the rights to use, copy, modify, merge, publish, distribute, sublicense,
-    and/or sell copies of the Software, and to permit persons to whom
-    the Software is furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be included
-    in all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-    IN THE SOFTWARE.
-*/
-
-#ifndef NN_SUB_INCLUDED
-#define NN_SUB_INCLUDED
-
-#include "../../protocol.h"
-
-extern struct nn_socktype *nn_sub_socktype;
-
-#endif
diff --git a/src/protocols/pubsub/xpub.c b/src/protocols/pubsub/xpub.c
index de108ea..b1484b9 100644
--- a/src/protocols/pubsub/xpub.c
+++ b/src/protocols/pubsub/xpub.c
@@ -191,14 +191,10 @@
      return socktype == NN_SUB ? 1 : 0;
 }
 
-static struct nn_socktype nn_xpub_socktype_struct = {
+struct nn_socktype nn_xpub_socktype = {
     AF_SP_RAW,
     NN_PUB,
     NN_SOCKTYPE_FLAG_NORECV,
     nn_xpub_create,
     nn_xpub_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_xpub_socktype = &nn_xpub_socktype_struct;
-
diff --git a/src/protocols/pubsub/xpub.h b/src/protocols/pubsub/xpub.h
index 59009a3..c810aa5 100644
--- a/src/protocols/pubsub/xpub.h
+++ b/src/protocols/pubsub/xpub.h
@@ -25,8 +25,6 @@
 
 #include "../../protocol.h"
 
-extern struct nn_socktype *nn_xpub_socktype;
-
 int nn_xpub_create (void *hint, struct nn_sockbase **sockbase);
 int nn_xpub_ispeer (int socktype);
 
diff --git a/src/protocols/pubsub/xsub.c b/src/protocols/pubsub/xsub.c
index e7b2646..4c3b302 100644
--- a/src/protocols/pubsub/xsub.c
+++ b/src/protocols/pubsub/xsub.c
@@ -33,7 +33,6 @@
 #include "../../utils/cont.h"
 #include "../../utils/fast.h"
 #include "../../utils/alloc.h"
-#include "../../utils/list.h"
 #include "../../utils/attr.h"
 
 struct nn_xsub_data {
@@ -237,14 +236,10 @@
     return socktype == NN_PUB ? 1 : 0;
 }
 
-static struct nn_socktype nn_xsub_socktype_struct = {
+struct nn_socktype nn_xsub_socktype = {
     AF_SP_RAW,
     NN_SUB,
     NN_SOCKTYPE_FLAG_NOSEND,
     nn_xsub_create,
     nn_xsub_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_xsub_socktype = &nn_xsub_socktype_struct;
-
diff --git a/src/protocols/pubsub/xsub.h b/src/protocols/pubsub/xsub.h
index 1d42692..ac3877f 100644
--- a/src/protocols/pubsub/xsub.h
+++ b/src/protocols/pubsub/xsub.h
@@ -25,8 +25,6 @@
 
 #include "../../protocol.h"
 
-extern struct nn_socktype *nn_xsub_socktype;
-
 int nn_xsub_create (void *hint, struct nn_sockbase **sockbase);
 int nn_xsub_ispeer (int socktype);
 
diff --git a/src/protocols/reqrep/rep.c b/src/protocols/reqrep/rep.c
index 6886041..0659a41 100644
--- a/src/protocols/reqrep/rep.c
+++ b/src/protocols/reqrep/rep.c
@@ -31,7 +31,6 @@
 #include "../../utils/alloc.h"
 #include "../../utils/chunkref.h"
 #include "../../utils/wire.h"
-#include "../../utils/list.h"
 
 #include <stddef.h>
 #include <string.h>
@@ -152,14 +151,10 @@
     return 0;
 }
 
-static struct nn_socktype nn_rep_socktype_struct = {
+struct nn_socktype nn_rep_socktype = {
     AF_SP,
     NN_REP,
     0,
     nn_rep_create,
     nn_xrep_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_rep_socktype = &nn_rep_socktype_struct;
-
diff --git a/src/protocols/reqrep/rep.h b/src/protocols/reqrep/rep.h
index 0f78b39..6231f7b 100644
--- a/src/protocols/reqrep/rep.h
+++ b/src/protocols/reqrep/rep.h
@@ -26,9 +26,6 @@
 #include "../../protocol.h"
 #include "xrep.h"
 
-extern struct nn_socktype *nn_rep_socktype;
-
-
 struct nn_rep {
     struct nn_xrep xrep;
     uint32_t flags;
diff --git a/src/protocols/reqrep/req.c b/src/protocols/reqrep/req.c
index 9d0d8d5..bd2c11b 100644
--- a/src/protocols/reqrep/req.c
+++ b/src/protocols/reqrep/req.c
@@ -35,7 +35,6 @@
 #include "../../utils/alloc.h"
 #include "../../utils/random.h"
 #include "../../utils/wire.h"
-#include "../../utils/list.h"
 #include "../../utils/attr.h"
 
 #include <stddef.h>
@@ -658,14 +657,10 @@
     }
 }
 
-static struct nn_socktype nn_req_socktype_struct = {
+struct nn_socktype nn_req_socktype = {
     AF_SP,
     NN_REQ,
     0,
     nn_req_create,
     nn_xreq_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_req_socktype = &nn_req_socktype_struct;
-
diff --git a/src/protocols/reqrep/req.h b/src/protocols/reqrep/req.h
index 6669244..deadfef 100644
--- a/src/protocols/reqrep/req.h
+++ b/src/protocols/reqrep/req.h
@@ -48,8 +48,6 @@
     struct nn_task task;
 };
 
-extern struct nn_socktype *nn_req_socktype;
-
 /*  Some users may want to extend the REQ protocol similar to how REQ extends XREQ.
     Expose these methods to improve extensibility. */
 void nn_req_init (struct nn_req *self,
diff --git a/src/protocols/reqrep/xrep.c b/src/protocols/reqrep/xrep.c
index dcd8fbf..f71f2f2 100644
--- a/src/protocols/reqrep/xrep.c
+++ b/src/protocols/reqrep/xrep.c
@@ -32,7 +32,6 @@
 #include "../../utils/alloc.h"
 #include "../../utils/random.h"
 #include "../../utils/wire.h"
-#include "../../utils/list.h"
 #include "../../utils/attr.h"
 
 #include <string.h>
@@ -291,14 +290,10 @@
     return socktype == NN_REQ ? 1 : 0;
 }
 
-static struct nn_socktype nn_xrep_socktype_struct = {
+struct nn_socktype nn_xrep_socktype = {
     AF_SP_RAW,
     NN_REP,
     0,
     nn_xrep_create,
     nn_xrep_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_xrep_socktype = &nn_xrep_socktype_struct;
-
diff --git a/src/protocols/reqrep/xrep.h b/src/protocols/reqrep/xrep.h
index a3b3ff3..c8b618c 100644
--- a/src/protocols/reqrep/xrep.h
+++ b/src/protocols/reqrep/xrep.h
@@ -72,6 +72,4 @@
 
 int nn_xrep_ispeer (int socktype);
 
-extern struct nn_socktype *nn_xrep_socktype;
-
 #endif
diff --git a/src/protocols/reqrep/xreq.c b/src/protocols/reqrep/xreq.c
index 392382f..7902866 100644
--- a/src/protocols/reqrep/xreq.c
+++ b/src/protocols/reqrep/xreq.c
@@ -29,7 +29,6 @@
 #include "../../utils/cont.h"
 #include "../../utils/fast.h"
 #include "../../utils/alloc.h"
-#include "../../utils/list.h"
 #include "../../utils/attr.h"
 
 struct nn_xreq_data {
@@ -235,14 +234,10 @@
     return socktype == NN_REP ? 1 : 0;
 }
 
-static struct nn_socktype nn_xreq_socktype_struct = {
+struct nn_socktype nn_xreq_socktype = {
     AF_SP_RAW,
     NN_REQ,
     0,
     nn_xreq_create,
     nn_xreq_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_xreq_socktype = &nn_xreq_socktype_struct;
-
diff --git a/src/protocols/reqrep/xreq.h b/src/protocols/reqrep/xreq.h
index 56497dc..665e659 100644
--- a/src/protocols/reqrep/xreq.h
+++ b/src/protocols/reqrep/xreq.h
@@ -54,6 +54,4 @@
 
 int nn_xreq_ispeer (int socktype);
 
-extern struct nn_socktype *nn_xreq_socktype;
-
 #endif
diff --git a/src/protocols/survey/respondent.c b/src/protocols/survey/respondent.c
index e43f059..f2a093b 100644
--- a/src/protocols/survey/respondent.c
+++ b/src/protocols/survey/respondent.c
@@ -21,7 +21,6 @@
     IN THE SOFTWARE.
 */
 
-#include "respondent.h"
 #include "xrespondent.h"
 
 #include "../../nn.h"
@@ -32,7 +31,6 @@
 #include "../../utils/fast.h"
 #include "../../utils/alloc.h"
 #include "../../utils/wire.h"
-#include "../../utils/list.h"
 
 #include <string.h>
 
@@ -173,14 +171,10 @@
     return 0;
 }
 
-static struct nn_socktype nn_respondent_socktype_struct = {
+struct nn_socktype nn_respondent_socktype = {
     AF_SP,
     NN_RESPONDENT,
     0,
     nn_respondent_create,
     nn_xrespondent_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_respondent_socktype = &nn_respondent_socktype_struct;
-
diff --git a/src/protocols/survey/respondent.h b/src/protocols/survey/respondent.h
deleted file mode 100644
index aabf72f..0000000
--- a/src/protocols/survey/respondent.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-    Copyright (c) 2012-2013 Martin Sustrik  All rights reserved.
-
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"),
-    to deal in the Software without restriction, including without limitation
-    the rights to use, copy, modify, merge, publish, distribute, sublicense,
-    and/or sell copies of the Software, and to permit persons to whom
-    the Software is furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be included
-    in all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-    IN THE SOFTWARE.
-*/
-
-#ifndef NN_RESPONDENT_INCLUDED
-#define NN_RESPONDENT_INCLUDED
-
-#include "../../protocol.h"
-
-extern struct nn_socktype *nn_respondent_socktype;
-
-#endif
diff --git a/src/protocols/survey/surveyor.c b/src/protocols/survey/surveyor.c
index 703cf30..0a07ac0 100644
--- a/src/protocols/survey/surveyor.c
+++ b/src/protocols/survey/surveyor.c
@@ -21,7 +21,6 @@
     IN THE SOFTWARE.
 */
 
-#include "surveyor.h"
 #include "xsurveyor.h"
 
 #include "../../nn.h"
@@ -36,7 +35,6 @@
 #include "../../utils/wire.h"
 #include "../../utils/alloc.h"
 #include "../../utils/random.h"
-#include "../../utils/list.h"
 #include "../../utils/attr.h"
 
 #include <string.h>
@@ -512,14 +510,10 @@
     return 0;
 }
 
-static struct nn_socktype nn_surveyor_socktype_struct = {
+struct nn_socktype nn_surveyor_socktype = {
     AF_SP,
     NN_SURVEYOR,
     0,
     nn_surveyor_create,
     nn_xsurveyor_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_surveyor_socktype = &nn_surveyor_socktype_struct;
-
diff --git a/src/protocols/survey/surveyor.h b/src/protocols/survey/surveyor.h
deleted file mode 100644
index b4bf514..0000000
--- a/src/protocols/survey/surveyor.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-    Copyright (c) 2012-2013 Martin Sustrik  All rights reserved.
-
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"),
-    to deal in the Software without restriction, including without limitation
-    the rights to use, copy, modify, merge, publish, distribute, sublicense,
-    and/or sell copies of the Software, and to permit persons to whom
-    the Software is furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be included
-    in all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-    IN THE SOFTWARE.
-*/
-
-#ifndef NN_SURVEYOR_INCLUDED
-#define NN_SURVEYOR_INCLUDED
-
-#include "../../protocol.h"
-
-extern struct nn_socktype *nn_surveyor_socktype;
-
-#endif
-
diff --git a/src/protocols/survey/xrespondent.c b/src/protocols/survey/xrespondent.c
index 6e628d2..ce4d238 100644
--- a/src/protocols/survey/xrespondent.c
+++ b/src/protocols/survey/xrespondent.c
@@ -32,7 +32,6 @@
 #include "../../utils/alloc.h"
 #include "../../utils/random.h"
 #include "../../utils/wire.h"
-#include "../../utils/list.h"
 #include "../../utils/attr.h"
 
 /*  Private functions. */
@@ -289,14 +288,10 @@
     return socktype == NN_SURVEYOR ? 1 : 0;
 }
 
-static struct nn_socktype nn_xrespondent_socktype_struct = {
+struct nn_socktype nn_xrespondent_socktype = {
     AF_SP_RAW,
     NN_RESPONDENT,
     0,
     nn_xrespondent_create,
     nn_xrespondent_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_xrespondent_socktype = &nn_xrespondent_socktype_struct;
-
diff --git a/src/protocols/survey/xrespondent.h b/src/protocols/survey/xrespondent.h
index 322a7a8..6afbfcf 100644
--- a/src/protocols/survey/xrespondent.h
+++ b/src/protocols/survey/xrespondent.h
@@ -29,8 +29,6 @@
 #include "../../utils/hash.h"
 #include "../utils/fq.h"
 
-extern struct nn_socktype *nn_xrespondent_socktype;
-
 #define NN_XRESPONDENT_OUT 1
 
 struct nn_xrespondent_data {
diff --git a/src/protocols/survey/xsurveyor.c b/src/protocols/survey/xsurveyor.c
index c2e5c9c..9a81d0a 100644
--- a/src/protocols/survey/xsurveyor.c
+++ b/src/protocols/survey/xsurveyor.c
@@ -28,9 +28,7 @@
 #include "../../utils/err.h"
 #include "../../utils/cont.h"
 #include "../../utils/fast.h"
-#include "../../utils/list.h"
 #include "../../utils/alloc.h"
-#include "../../utils/list.h"
 #include "../../utils/attr.h"
 
 #include <stddef.h>
@@ -217,14 +215,10 @@
     return socktype == NN_RESPONDENT ? 1 : 0;
 }
 
-static struct nn_socktype nn_xsurveyor_socktype_struct = {
+struct nn_socktype nn_xsurveyor_socktype = {
     AF_SP_RAW,
     NN_SURVEYOR,
     0,
     nn_xsurveyor_create,
     nn_xsurveyor_ispeer,
-    NN_LIST_ITEM_INITIALIZER
 };
-
-struct nn_socktype *nn_xsurveyor_socktype = &nn_xsurveyor_socktype_struct;
-
diff --git a/src/protocols/survey/xsurveyor.h b/src/protocols/survey/xsurveyor.h
index fe7f8b4..5f0fbe3 100644
--- a/src/protocols/survey/xsurveyor.h
+++ b/src/protocols/survey/xsurveyor.h
@@ -28,8 +28,6 @@
 #include "../utils/dist.h"
 #include "../utils/fq.h"
 
-extern struct nn_socktype *nn_xsurveyor_socktype;
-
 struct nn_xsurveyor_data {
     struct nn_pipe *pipe;
     struct nn_dist_data outitem;