ldns(3) Library Functions Manual ldns(3)

# [NAME](#NAME)

ldns\_tcp\_send\_query, ldns\_tcp\_read\_wire, ldns\_tcp\_connect - tcp queries

# [SYNOPSIS](#SYNOPSIS)

#include &lt;stdint.h&gt;  
#include &lt;stdbool.h&gt;

#include &lt;ldns/ldns.h&gt;

ssize\_t ldns\_tcp\_send\_query(ldns\_buffer \*qbin, int sockfd, const struct sockaddr\_storage \*to, socklen\_t tolen);

uint8\_t* ldns\_tcp\_read\_wire(int sockfd, size\_t \*size);

int ldns\_tcp\_connect(const struct sockaddr\_storage \*to, socklen\_t tolen, struct timeval timeout);

# [DESCRIPTION](#DESCRIPTION)

*ldns\_tcp\_send\_query*() send a query via tcp to a server. Don't want for the answer

**qbin**: the buffer to send  
**sockfd**: the socket to use  
**to**: which ip to send it  
**tolen**: socketlen  
Returns number of bytes sent

*ldns\_tcp\_read\_wire*() This routine may block. Use ldns\_tcp\_read\_wire\_timeout, it checks timeouts. Gives back a raw packet from the wire and reads the header data from the given socket. Allocates the data (of size size) itself, so don't forget to free

**sockfd**: the socket to read from  
**size**: the number of bytes that are read  
Returns the data read

*ldns\_tcp\_connect*() Create a tcp socket to the specified address This function has the flaw that it returns 0 on failure, but 0 could be a valid socket. Please use ldns\_tcp\_connect2 instead of this function.  
**to**: ip and family  
**tolen**: length of to  
**timeout**: timeout for the connect attempt  
Returns a socket descriptor or 0 on failure

# [AUTHOR](#AUTHOR)

The ldns team at NLnet Labs.

# [REPORTING BUGS](#REPORTING_BUGS)

Please report bugs to dns-team@nlnetlabs.nl or on GitHub at https://github.com/NLnetLabs/ldns/issues

# [COPYRIGHT](#COPYRIGHT)

Copyright (c) 2004 - 2006 NLnet Labs.

Licensed under the BSD License. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# [SEE ALSO](#SEE_ALSO)

*ldns\_send*, *ldns\_pkt*, *ldns\_resolver*. And **perldoc Net::DNS**, **RFC1034**, **RFC1035**, **RFC4033**, **RFC4034** and **RFC4035**.

# [REMARKS](#REMARKS)

This manpage was automatically generated from the ldns source code.

30 May 2006

---

Document: ldns_tcp_read_wire(3) from ldns 1.9.2-r3 (Chainguard OS)
Source: https://github.com/NLnetLabs/ldns.git
