home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / perl / 5682 < prev    next >
Encoding:
Internet Message Format  |  1992-09-02  |  2.5 KB

  1. Path: sparky!uunet!news.univie.ac.at!blekul11!frmop11!barilvm!vms.huji.ac.il!wisipc.weizmann.ac.il!menora.weizmann.ac.il!dov
  2. Newsgroups: comp.lang.perl
  3. Subject: Re: select misses pending data on socket
  4. Message-ID: <1992Sep2.122937.15736@wisipc.weizmann.ac.il>
  5. From: dov@menora.weizmann.ac.il (Dov Grobgeld)
  6. Date: Wed, 2 Sep 1992 12:29:37 GMT
  7. Sender: news@wisipc.weizmann.ac.il
  8. References: <1992Sep1.213109.26481@netlabs.com>
  9. Organization: Weizmann Institute of Science, Computation Center.
  10. Lines: 48
  11.  
  12. lwall@netlabs.com (Larry Wall) writes:
  13. : In article <1992Aug31.201931.14111@uvaarpa.Virginia.EDU> dov@menora.weizmann.ac.il writes:
  14. : : The print line of $rout shows that select reports that there is no data
  15. : : to be read on the socket. How can that be?
  16. :
  17. : Because there isn't any data to be read on the socket.  It's already been
  18. : read into the stdio buffers.
  19. :
  20. : Don't use select with <>.  Use sysread() or recv() instead.
  21. :
  22. : I suppose I really ought to make select work with stdio, but that can
  23. : get gory...
  24. :
  25. : Larry
  26.  
  27. So many strange functions (select(), recv(), sysread(), fileno(), vec() )
  28. to do the conceptually simple task of:
  29.  
  30.    "Check if there are apples under the tree, and if so, pick them,
  31.     but don't hang around waiting for them to fall."
  32.  
  33. I'm used to it being very simple to implement well defined problems
  34. like this in Perl (yes, I'm spoiled ;-), but this seems to be an exception.
  35.  
  36. It seems like the socket related functions, as opposed to the rest of
  37. Perl, are just directly copied versions of the underlying Unix functions.
  38. If socket support was provided in a different operating system, it
  39. wouldn't map very well to these function names I believe.
  40.  
  41. Anyhow, I seem to have gotten to grips with these calls now and have
  42. rewritten the client program from the Camel book without any forks.
  43. Perhaps such a program should be included in the next version (generation)
  44. of the (family of) Camel(s).
  45.  
  46. Just one more question about the sockets. How do I detect if the server
  47. I'm connected to has closed down the connection?
  48.  
  49.   @apple= ("Just ","Another ","Perl ","Hacker,"); $tree=0; $branch=1;
  50.   print while $_ = splice(@apple,$tree,$branch);
  51.  
  52. --
  53.                                                         ___   ___
  54.                                                       /  o  \   o \
  55. Dov Grobgeld                                         ( o  o  ) o   |
  56. The Weizmann Institute of Science, Israel             \  o  /o  o /
  57. "Where the tree of wisdom carries oranges"              | |   | |
  58.                                                        _| |_ _| |_
  59.  
  60.