Index: uspace/srv/net/dnsres/dns_msg.c
===================================================================
--- uspace/srv/net/dnsres/dns_msg.c	(revision f85ed4b7134354b6f33ed02f299272b51eb157d6)
+++ uspace/srv/net/dnsres/dns_msg.c	(revision 08a63825c3c6ad29b01defcc423d9915711938cb)
@@ -35,4 +35,5 @@
 
 #include <bitops.h>
+#include <byteorder.h>
 #include <errno.h>
 #include <stdint.h>
@@ -87,13 +88,15 @@
 				buf[pi] = (uint8_t)lsize;
 
+			lsize = 0;
+			pi = di;
+			++di;
+
 			if (c == '\0')
 				break;
-
-			pi = di;
+		} else {
+			if (buf != NULL && di < buf_size)
+				buf[di] = c;
 			++di;
-		} else {
 			++lsize;
-			if (buf != NULL && di < buf_size)
-				buf[di++] = c;
 		}
 	}
@@ -126,5 +129,8 @@
 		return rc;
 
+	printf("name_size=%zu\n", name_size);
+
 	*act_size = name_size + sizeof(uint16_t) + sizeof(uint16_t);
+	printf("act_size=%zu\n", *act_size);
 	if (buf == NULL)
 		return EOK;
@@ -138,5 +144,4 @@
 	di += sizeof(uint16_t);
 
-	*act_size = di;
 	return EOK;
 }
@@ -151,7 +156,7 @@
 	int rc;
 
-	hdr.id = msg->id;
-
-	hdr.opbits =
+	hdr.id = host2uint16_t_be(msg->id);
+
+	hdr.opbits = host2uint16_t_be(
 	    (msg->qr << OPB_QR) |
 	    (msg->opcode << OPB_OPCODE_l) |
@@ -160,7 +165,8 @@
 	    (msg->rd ? BIT_V(uint16_t, OPB_RD) : 0) |
 	    (msg->ra ? BIT_V(uint16_t, OPB_RA) : 0) |
-	    msg->rcode;
-
-	hdr.qd_count = list_count(&msg->question);
+	    msg->rcode
+	);
+
+	hdr.qd_count = host2uint16_t_be(list_count(&msg->question));
 	hdr.an_count = 0;
 	hdr.ns_count = 0;
@@ -168,4 +174,5 @@
 
 	size = sizeof(dns_header_t);
+	printf("dns header size=%zu\n", size);
 
 	list_foreach(msg->question, link) {
@@ -175,4 +182,5 @@
 			return rc;
 
+		printf("q_size=%zu\n", q_size);
 		size += q_size;
 	}
@@ -193,4 +201,5 @@
 	}
 
+	printf("-> size=%zu, di=%zu\n", size, di);
 	*rdata = data;
 	*rsize = size;
Index: uspace/srv/net/dnsres/query.c
===================================================================
--- uspace/srv/net/dnsres/query.c	(revision f85ed4b7134354b6f33ed02f299272b51eb157d6)
+++ uspace/srv/net/dnsres/query.c	(revision 08a63825c3c6ad29b01defcc423d9915711938cb)
@@ -35,4 +35,5 @@
 
 #include <errno.h>
+#include <mem.h>
 
 #include "dns_std.h"
@@ -53,4 +54,6 @@
 	question.qtype = DTYPE_A;
 	question.qclass = DC_IN;
+
+	memset(&msg, 0, sizeof(msg));
 
 	list_initialize(&msg.question);
Index: uspace/srv/net/dnsres/transport.c
===================================================================
--- uspace/srv/net/dnsres/transport.c	(revision f85ed4b7134354b6f33ed02f299272b51eb157d6)
+++ uspace/srv/net/dnsres/transport.c	(revision 08a63825c3c6ad29b01defcc423d9915711938cb)
@@ -35,4 +35,8 @@
 
 #include <errno.h>
+#include <net/in.h>
+#include <net/inet.h>
+#include <net/socket.h>
+#include <stdlib.h>
 
 #include "dns_msg.h"
@@ -40,4 +44,5 @@
 #include "transport.h"
 
+#include <stdio.h>
 int dns_request(dns_message_t *req, dns_message_t **rresp)
 {
@@ -46,12 +51,40 @@
 	void *req_data;
 	size_t req_size;
+	struct sockaddr_in addr;
+	int fd;
+
+	addr.sin_family = AF_INET;
+	addr.sin_port = htons(53);
+	addr.sin_addr.s_addr = htonl((192 << 24) | (168 << 16) | (0 << 8) | 1);
+
+	req_data = NULL;
+	fd = -1;
 
 	rc = dns_message_encode(req, &req_data, &req_size);
 	if (rc != EOK)
-		return rc;
+		goto error;
+
+	fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
+	if (fd < 0) {
+		rc = EIO;
+		goto error;
+	}
+
+	printf("fd=%d req_data=%p, req_size=%zu\n", fd, req_data, req_size);
+	rc = sendto(fd, req_data, req_size, 0, (struct sockaddr *)&addr,
+	    sizeof(addr));
+	if (rc != EOK)
+		goto error;
 
 	resp = NULL;
 	*rresp = resp;
 	return EOK;
+
+error:
+	if (req_data != NULL)
+		free(req_data);
+	if (fd >= 0)
+		closesocket(fd);
+	return rc;
 }
 
Index: uspace/srv/net/udp/sock.c
===================================================================
--- uspace/srv/net/udp/sock.c	(revision f85ed4b7134354b6f33ed02f299272b51eb157d6)
+++ uspace/srv/net/udp/sock.c	(revision 08a63825c3c6ad29b01defcc423d9915711938cb)
@@ -359,13 +359,13 @@
 			rc = EOK;
 			break;
-/*		case TCP_ENOTEXIST:
+		case UDP_ENORES:
 			rc = ENOTCONN;
 			break;
-		case TCP_ECLOSING:
-			rc = ENOTCONN;
-			break;
-		case TCP_ERESET:
-			rc = ECONNABORTED;
-			break;*/
+		case UDP_EUNSPEC:
+			rc = EINVAL;
+			break;
+		case UDP_ENOROUTE:
+			rc = EIO;
+			break;
 		default:
 			assert(false);
