Could you explain how <$sock> is a pretyy bad idea? Some script I wrote in this mechanism seems work well by far.
If it's really exist some inevitable bug or flaw, I have to modify to fix.
Thanks!
I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction
| [reply] |
If it's really exist some inevitable bug or flaw, I have to modify to fix.
It appears that English may not be your primary language. I didn't refer to an inevitable problem. In the general case it is a bad idea. In specific cases it certainly can work (as you have seen).
<$sock> doesn't terminate until it finds end-of-record (EOR, $/) or end-of-file (due to shutdown or close). I often see this being used in cases where no EOR is expected and so the script just hangs. Even if you have a somewhat unusual protocol over your sockets where every transaction is supposed to terminate with an EOR, using <$sock> still means that you script "just hangs" when something goes wrong with regard to the EOR. It is much better to be able to report "I got some data but it didn't have an EOR on the end" than to just have a "hung" script and no indication why it is hung.
It is also unsafe to use <$sock> together with select (which almost any socket-based server written in Perl should probably be using).
| [reply] [d/l] [select] |
Thanks for your explanation! IMHO, that means <$sock> is merely used in chat script or ascii file transfer. Is it right? If so, thank God, I can still enjoy this weekend. ;)
BTW:
I really appreciate your kindness if you can correct my English mistake. I'm thirsty for communicate with perl gurus fluently. ;)
I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction
| [reply] |