]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
udp and tcp bgsend implemented
authorMiek Gieben <miekg@NLnetLabs.nl>
Tue, 10 Jan 2006 13:27:14 +0000 (13:27 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Tue, 10 Jan 2006 13:27:14 +0000 (13:27 +0000)
ldns/net.h
net.c

index 81044fdbb51bef1009c0198e81360e857f24b566..a74a86fccdbaa684f7c57bc64bd16a1fc7d01025 100644 (file)
  */
 ldns_status ldns_udp_send(uint8_t **result, ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout, size_t *answersize);
 
+/**
+ * Send an udp query and don't wait for an answer but return
+ * the socket
+ * \param[in] qbin the ldns_buffer to be send
+ * \param[in] to the ip addr to send to
+ * \param[in] tolen length of the ip addr
+ * \param[in] timeout the timeout value for the network
+ * \return the socket used
+ */
+
+int ldns_udp_sendbg(ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout);
+
+/**
+ * Send an tcp query and don't wait for an answer but return
+ * the socket
+ * \param[in] qbin the ldns_buffer to be send
+ * \param[in] to the ip addr to send to
+ * \param[in] tolen length of the ip addr
+ * \param[in] timeout the timeout value for the network
+ * \return the socket used
+ */
+int ldns_tcp_sendbg(ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout);
+
 /**
  * Sends a buffer to an ip using tcp and return the respons as a ldns_pkt
  * \param[in] qbin the ldns_buffer to be send
diff --git a/net.c b/net.c
index a46698f2a3544211265e2c9a449f6b3e72a60be5..3dcecbea3be485cbb0b4e4c22567331b4c9915e2 100644 (file)
--- a/net.c
+++ b/net.c
@@ -200,6 +200,23 @@ ldns_udp_send(uint8_t **result, ldns_buffer *qbin, const struct sockaddr_storage
        return LDNS_STATUS_OK;
 }
 
+int
+ldns_udp_bgsend(ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout)
+{
+       int sockfd;
+
+       sockfd = ldns_udp_connect(to, timeout);
+
+       if (sockfd == 0) {
+               return LDNS_STATUS_ERR;
+       }
+
+       if (ldns_udp_send_query(qbin, sockfd, to, tolen) == 0) {
+               return LDNS_STATUS_ERR;
+       }
+       return sockfd;
+}
+
 /* 
  * ldns_tcp_server_connect
  *
@@ -447,6 +464,24 @@ ldns_tcp_send(uint8_t **result,  ldns_buffer *qbin, const struct sockaddr_storag
        return LDNS_STATUS_OK;
 }
 
+int
+ldns_tcp_bgsend(ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout)
+{
+       int sockfd;
+       
+       sockfd = ldns_tcp_connect(to, tolen, timeout);
+       
+       if (sockfd == 0) {
+               return LDNS_STATUS_ERR;
+       }
+       
+       if (ldns_tcp_send_query(qbin, sockfd, to, tolen) == 0) {
+               return LDNS_STATUS_ERR;
+       }
+       
+       return sockfd;
+}
+
 /* Move other function that use sockaddr to here, so that 
  * all networking code is contained in one file
  */