home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / perl / 5640 < prev    next >
Encoding:
Text File  |  1992-08-31  |  1.5 KB  |  40 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!koonda.acci.com.au!ggr
  3. From: ggr@koonda.acci.com.au (Greg Rose)
  4. Subject: Re: perl socket filehandles
  5. Message-ID: <9224508.15763@mulga.cs.mu.OZ.AU>
  6. Sender: news@cs.mu.OZ.AU
  7. Organization: Australian Computing and Communications Institute
  8. References: <1992Aug31.181515.4294@colorado.edu>
  9. Date: Mon, 31 Aug 1992 22:41:14 GMT
  10. Lines: 28
  11.  
  12. In article <1992Aug31.181515.4294@colorado.edu> dyker@locutus.colorado.edu (Barbara Dyker) writes:
  13. >I'm trying to write a program that will get started from
  14. >inetd.  All I want to do is a getpeername on file descriptor
  15. >zero.  How do I assign in perl a particular value to a socket
  16. >filehandle so I can do things like getpeername?  I tried
  17. >doing simply   
  18. >    $mysockaddr = getpeername(0);
  19. >which gives me zip.
  20. >
  21. >Sockets are not really my thing so I could be missing something
  22. >fundamentally trivial.  It seems that if I wanted to do a
  23. >getsockname I would have the same problem.  In this
  24. >particular case I don't care much about my end.  Anyone
  25. >have such a program I could use as an example?  
  26.  
  27. I tried to reply by e-mail but something went wrong, so anyway...
  28.  
  29. The socket handling stuff from perl has been rewritten to use perl
  30. filehandles instead of file descriptors -- you are NOT directly
  31. calling the C library. So what you want is
  32.  
  33.     $mysockaddr = getpeername(STDIN);
  34.  
  35. and it will work as expected.
  36.  
  37. --
  38. Greg Rose                 Australian Computing and Communications Institute
  39. ggr@acci.com.au                                              +61 3 282 2532
  40.