in reply to I need an array of filehandles.
1) Why download a file over multiple file handles?
If the answer is 'performance' be very sure to test to see if it is faster in the environment you expect it to be used, because it shouldn't be.
For a large transfer (and why else do a multiple fetch?) TCP should auto-adjust to get the best from the link between the client and server with only one connection.
If the answer is 'to avoid refetching the entire file if one transfer stalls/fails' then I don't think you need to do this - there is support in HTTP for requesting parts of files so you can resume a transfer if it fails.
2) Reading from multiple file descriptors. (I'm not 100% sure about this, but think this is right).
If you read from a file descriptor with <$fh>, perl does a 'blocking read'. This means the process will sleep until data arrives on that connection. In particular you won't get woken up if data arrives on one of your other file descriptors. For this kind of think you want a 'select' statement, to tell the O/S that you want to do some work when data arrives on any one of the specified file descriptors.
When the select returns and tells you there is data waiting, you then need to read from the file handle. Again, if you use <$fh> to read, you need to be careful to check what '$/' is set to, because the read will block until this character sequence is seen.
In summary, a multiple-socket client is a little more tricky than just having more file handles open and also I don't see why you'd need one - but hey - you probably have your reasons.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: I need an array of filehandles.
by Anonymous Monk on Apr 25, 2000 at 20:53 UTC | |
by Punto (Scribe) on Apr 25, 2000 at 21:29 UTC |