This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gethostbyname


On Mon, Aug 13, 2001 at 04:11:18PM -0700, Dan Conti wrote:

Hi Dan

I've done the same, implement a DNS client for eCos. Im currently
waiting for Management to sign a copywrite release so it can be
contributed to eCos.

> i wrote a simple dns client for eCos and was looking at adding it into
> the kernel and, naturally, populating gethostbyname() 

Its not part of the kernel, its part of the network stack. You should
place it into packages/net/tcpip/current/src/lib/
 
> i haven't been able to find an example of how gethostbyname() is
> implemented. specifically, is it possible to implement without dynamic
> memory.

I looked at the resolver library that comes with bind. I then decided
it was too complex for what i needed and did it a completly different
way. Yes, you need some sort of dynamic memory. To make this work
correctly in a multi threaded enviroment i used malloc and the per
thread data index pool to hold the information that each threads
need. Each call to gethostbyname frees the results from the previous
call and then creates the state for the current call. This fits the
BSD symantics

> and can i assume endhostent() will be explicitely called?

Nope. I've seen very few real programs call that. If you port
something from Unix its unlikly to call this function. Something you
hard craft yourself may. 

> i'm
> not too familiar with convention on these items. is gethostbyname() a
> kernel fun in *bsd? i couldn't find it when i looked. pointers
> appreciated :)

No, its in libc. All the major Open Source Unix systems use the
resolve library from bind. 

        Andrew


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]