[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Communications, Volume 2

res_send Subroutine


Sends a query to a name server and retrieves a response.


Standard C Library (libc.a)


#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>

int res_send (MessagePtr, MessageLength, Answer, AnswerLength)
char * MsgPtr;
int MsgLength;
char * Answer;
int AnswerLength;


The res_send subroutine sends a query to name servers and calls the res_init subroutine if the RES_INIT option of the _res structure is not set. This subroutine sends the query to the local name server and handles time outs and retries.

The res_send subroutine is one of a set of subroutines that form the resolver, a set of functions that resolve domain names. Global information used by the resolver subroutines is kept in the _res structure. The /usr/include/resolv.h file contains the _res structure definition.

All applications containing the res_send subroutine must be compiled with _BSD set to a specific value. Acceptable values are 43 and 44. In addition, all socket applications must include the BSD libbsd.a library.


MessagePtr Points to the beginning of a message.
MessageLength Specifies the length of the message.
Answer Points to an address where the response is stored.
AnswerLength Specifies the size of the answer area.

Return Values

Upon successful completion, the res_send subroutine returns the length of the message.

If the res_send subroutine is unsuccessful, the subroutine returns a -1.


                          Contains general name server and domain name information.

Related Information

The dn_comp subroutine, dn_expand subroutine, _getlong subroutine, _getshort subroutine, putlong subroutine, putshort subroutine, res_init subroutine, res_mkquery subroutine, res_ninit Subroutine, res_query subroutine, res_search subroutine.

Sockets Overview and Understanding Domain Name Resolution in AIX 5L Version 5.2 Communications Programming Concepts.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]