home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.programmer
- Path: sparky!uunet!news.encore.com!epeterso
- From: epeterso@encore.com (Eric Peterson)
- Subject: Re: getservbyname(), getprotobyname(), gethostbyname()
- Reply-To: epeterson@encore.com (Eric Peterson)
- Organization: Encore Computer Corp, Umax Development
- Date: Wed, 2 Sep 1992 19:29:47 GMT
- Message-ID: <Btyu5o.Cxv@encore.com>
- News-Software: NN 6.4.16
- References: <1992Sep2.184623.3900@Urmel.Informatik.RWTH-Aachen.DE>
- Sender: news@encore.com (Usenet readnews user id)
- Nntp-Posting-Host: sysgem1.encore.com
- Lines: 34
-
- berg@physik.tu-muenchen.de (Stephen R. van den Berg) writes:
-
- | Now, in order to that, I have to find out the following:
- |
- | 1. gethostbyname("localhost.or.something.else")
- | 2. getservbyname("biff")
- | 3. getprotobyname("udp")
- |
- | Well, so far so good, the only trouble is, these calls are done every time
- | when mail arrives. I was wondering, what is common practice in this case?
- |
- | a. Go by the book and make all three calls at runtime?
- | b. Do 1. and 2. at runtime, 3. at compile time?
- | c. Do 1. at runtime, 2. and 3. at compile time?
- | d. Do all three at compile time? (By compile-time I mean: compile
- | a separate program that makes these calls, and then use the output
- | from this program to hardcode the number(s) in the real program).
- |
- | I personally like a., but I might suspect some performance penalty here
- | (depending on the configuration every one of these calls causes several files
- | to be opened and miscellaneous network-traffic to be generated).
-
- I would consider *ONLY* (a) to be acceptable practice. These functions
- are system database query functions, and the intent of making them
- functions and not, say, header file definitions was to sever the dependency
- between the code and the data (ie, you wouldn't have to rebuild if you
- decided to change the UDP protocol number).
-
- Having said that, you could probably safely get away with hard-coding
- these numbers into your code if you wanted to (except for the
- gethostbyname() call) since they are so common that they probably
- won't change.
-
- Eric
-