home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / programm / 4520 < prev    next >
Encoding:
Text File  |  1992-09-02  |  2.0 KB  |  49 lines

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