home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / rec / games / mud / misc / 1729 < prev    next >
Encoding:
Text File  |  1992-12-24  |  1.5 KB  |  35 lines

  1. Newsgroups: rec.games.mud.misc
  2. Path: sparky!uunet!paladin.american.edu!gatech!darwin.sura.net!ra!wintermute.phys.psu.edu!atlantis.psu.edu!handel!stine
  3. From: stine@handel.psu.edu (Jeffrey Stine)
  4. Subject: Re: Note to any fellow DikuMUD coders...
  5. Message-ID: <jck1H8e5mb@atlantis.psu.edu>
  6. Sender: news@atlantis.psu.edu (Usenet)
  7. Organization: Penn State University
  8. References: <3331@bsu-cs.bsu.edu> <1992Dec24.114107.18992@meiko.com>
  9. Date: Thu, 24 Dec 92 23:21:42 GMT
  10. Lines: 23
  11.  
  12. In article <1992Dec24.114107.18992@meiko.com> gordon@meiko.com (Gordon Henderson) writes:
  13. >In article <3331@bsu-cs.bsu.edu> decker@bsu-cs.bsu.edu (Alexus Mel Lynn) writes:
  14. >>
  15. >>Have any of you fellow coders worked with getpeername?  (I've ported some
  16. >>lpmud code over my very hacked diku, but it always dies on the getpeername...)
  17. >>
  18. >>I've made sure it's not something stupid like bad parameters, etc.
  19. >
  20. >I use this in a MUD that I am running to get the ip address of the caller:
  21. [...(code using getpeername snipped)]
  22. >--
  23. >  Gordon (Irn-Bru) Henderson
  24. >
  25.  Throw it out. Get rid of all that code that uses getpeername().
  26. Why waste a system call on something that accept() will do for you?
  27.  If you are using a connection oriented, single process server there
  28. is no reason why you shouldn't get the info you need from accept().
  29.  
  30.   int accept(int sockfd, struct sockaddr *peer, int *addrlen);
  31.  
  32.  It will complete the 5-tuple association with foreign address just like
  33. the getpeername call.  getpeername is primarily needed in applications
  34. called by inetd, which does the accept for them. 
  35.