home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!paladin.american.edu!darwin.sura.net!spool.mu.edu!uwm.edu!ogicse!news.u.washington.edu!carson.u.washington.edu!donn
- From: donn@carson.u.washington.edu (Donn Cave)
- Newsgroups: comp.unix.programmer
- Subject: Re: getservbyname(), getprotobyname(), gethostbyname()
- Message-ID: <1992Sep15.163829.26987@u.washington.edu>
- Date: 15 Sep 92 16:38:29 GMT
- Article-I.D.: u.1992Sep15.163829.26987
- References: <1992Sep2.184623.3900@Urmel.Informatik.RWTH-Aachen.DE> <Btyu5o.Cxv@encore.com>
- Sender: news@u.washington.edu (USENET News System)
- Organization: University of Washington
- Lines: 45
-
- epeterso@encore.com (Eric Peterson) writes:
-
- >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 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.
-
- Not only that, but perhaps you don't want to know if they do change. Maybe
- I don't understand something here, but doesn't getservbyname("biff") tell
- me what port biff uses on_my_local_system? If I want to connect to the
- "biff" service on "localhost.or.something.else", it's to be hoped that they
- will both use the same port, but if they don't, I certainly don't want to
- know about the local installation.
-
- /etc/services is a useful way to advertise port numbers between programmers
- and system administrators, who otherwise would have no way to reserve a port,
- but whether applications should refer to that file is open to question,
- depending particularly on the system administration context.
-
- Donn Cave, University Computing Services, University of Washington
- donn@cac.washington.edu
-