| | |
/etc/resolv.conf
![]() |
The conf file is just a textfile, so you can use standard c++ file-acces:
C Syntax (Toggle Plain Text)
#include <fstream> [....] std::ifstream in_file("/etc/resolv.conf"); if (!in_file.is_open()) std::cout << "error opening file"; else // do stuff
•
•
Join Date: Mar 2008
Posts: 41
Reputation:
Solved Threads: 7
Thanks for your reply. I have to use libraries to open this file.
With the help of the library routines I can add name server,
read the contents etc. Does this possible with Resolver library(http://swoolley.org/man.cgi/resolver)? Please let me know,
if need more info.
With the help of the library routines I can add name server,
read the contents etc. Does this possible with Resolver library(http://swoolley.org/man.cgi/resolver)? Please let me know,
if need more info.
Last edited by RenjithVR; Dec 2nd, 2008 at 9:34 am.
•
•
•
•
Hi,
Hi All,
Can anyone tell me about a library that helps me to read contents from /etc/resolv.conf file and also update the same file with new entries. Does this possible with Resolver library routines? Any useful links or sample programs regarding this? Thanks in advance.
Renjith
Last edited by stephen84s; Dec 2nd, 2008 at 10:29 am.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
"How to ask questions the smart way ?"
"How to ask questions the smart way ?"
•
•
Join Date: Mar 2008
Posts: 41
Reputation:
Solved Threads: 7
If you look at the man resolv.conf, you can see different configuration options. I have to use some of those options. Is it possible to do with the 'resolver', a set of routines in the C library. Can I use those set of routines in my program to access/update resolv.conf file? or any other library available to do this?
Although I have never tried it, I have read the manual pages of both resolv.conf and resolver, and I found the following line which would interest you :-
This is from the resolv.conf manual page.
And this is from the resolver manual page:-
So I guess you can read the resolv.conf file using resolver but I could not find any method that would actually write back to it.
This is from the resolv.conf manual page.
•
•
•
•
The resolver is a set of routines in the C library that provide access to the Internet Domain Name System (DNS). The resolver configuration file contains information that is read by the resolver routines the first time they are invoked by a process.
•
•
•
•
The res_init() function reads the configuration files (see resolv.conf(5)) to get the default domain name, search order and name server address(es). If no server is given, the local host is tried. If no domain is given, that associated with the local host is used. It can be overridden with the environment variable LOCALDOMAIN. res_init() is normally executed by the first call to one of the other functions.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
"How to ask questions the smart way ?"
"How to ask questions the smart way ?"
![]() |
Similar Threads
- DNS Problem - rndc: connect failed: connection refused (*nix Software)
- sendmail mail server (Linux Servers and Apache)
- Kubuntu Internet (*nix Software)
- How To Install Dns in Linux ? (Domains and DNS)
- Windows - Linux Shared Internet (Networking Hardware Configuration)
- network segmentation (Network Security)
- Apache Tomcat and IIS 6 with JK2 (Windows Servers and IIS)
- Sendmail problem (*nix Software)
- New to Linux (Getting Started and Choosing a Distro)
Other Threads in the C Forum
- Previous Thread: Warning: Comparison between pointer and integer (mingw 5.1.4)
- Next Thread: Optimizing OpenGL (SwapBuffer being slow)
| Thread Tools | Search this Thread |
* adobe ansi api array arrays bash binarysearch calculate centimeter char cm convert copyanyfile copypdffile createcopyoffile createprocess() csyntax directory dynamic fflush file floatingpointvalidation fork forloop frequency getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux hardware highest homework i/o ide inches initialization intmain() iso km linked linkedlist linux linuxsegmentationfault list logical_drives loopinsideloop. lowest match matrix microsoft motherboard mqqueue mysql oddnumber odf open opendocumentformat opensource openwebfoundation pattern pdf performance pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scanf scheduling segmentationfault send shape single socketprogramming stack standard strchr string suggestions test unix urboc user variable voidmain() whythiscodecausesegmentationfault win32api windows.h






