ckd@cs.bu.edu (Christopher Davis) (09/25/90)
Well, since you were all so helpful with my last request (thanks, folks!) I've come back for more... I have a program which binds two sockets, which we can call FOO and BAR. I want to read from *both* of them asynchronously as the information comes in. I'm used to using while(<FOO>) to get information from one, but how do I read from whichever one has data? Note: I need to keep track of which socket the data comes in on, so I don't think while(<FOO> || <BAR>) would work... --Chris -- Christopher Davis, BU SMG '90 <ckd@cs.bu.edu> <...!bu.edu!bu-cs!ckd> "Dammit, we're all going to die, let's die doing something *useful*!" --Hal Clement on comments that space exploration is dangerous
worley@compass.com (Dale Worley) (09/26/90)
From: ckd@cs.bu.edu (Christopher Davis) I have a program which binds two sockets, which we can call FOO and BAR. I want to read from *both* of them asynchronously as the information comes in. I'm used to using while(<FOO>) to get information from one, but how do I read from whichever one has data? Use select() with four arguments. It allows you to wait for I/O to be ready on any combination of filehandles, and returns telling you which ones are ready. Dale Worley Compass, Inc. worley@compass.com -- Necessity is the plea for every infringement of human freedom. It is the argument of tyrants; it is the creed of slaves. -- William Pitt