-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
Hi Brandom. On Tue, 13 Oct 2015 10:08:27 -0400 Brandon McCaig <[email protected]> wrote: > On Tue, Oct 13, 2015 at 6:34 AM, David Emanuel da Costa Santiago > <[email protected]> wrote: > > Hi! > > Hello, > > > THanks for your suggestion. > > I assume this was off-list because I didn't get it. Also consider > bottom-posting or interleaved posting for easier reading. Noted. > > > I changed my code to: > > > > sub _read_from_socket{ > > my ($select) = @_; > > > > my ($output, $buffer) = ('', ''); > > my $socket = undef; > > do { > > $socket = ($select->can_read(0.1))[0]; > > } while (!defined $socket); > > You're essentially manually blocking your code here. Until you can > read the program will be stuck in that loop, blocked/hung. It's no > different than just reading without IO::Select (which probably wastes > fewer CPU cycles too). Thanks. I'll remove the select, and leave the read (it was how i had it before). > > In general it would depend on the protocol you're using. _Should_ > there always be data when you go to read or could the remote end have > nothing to send you? You can try to rearrange your program to handle > the case when there is no data. Instead of looping until can_read(), > try printing or logging a diagnostic message and either moving on to > other work, putting the program to sleep to try again after some > period of time, or exit 1. > > Perhaps your troubles aren't code and are instead network stability. > If your network isn't stable enough to receive the packets then there > isn't much you can do within software to fix it. > Yes i also believe so. Thanks! David Santiago > > -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWHU0IAAoJEJ/OLjwuDYzKCdQH/AsSXpit4TB8y/zHtGJgqpvc gkh8rsKGNBtNCfyHF8P30MbH2RUOc/MjoZ9Y6+LqkXpqHv7fyiAkCfAKZ2RRO9IX QQPWbE8rjdXNbqaK60oj+TmUpkCASwKIGAl7cQsezG4YRdPoqibhzYnvycfWNbvt 2BrUkad4h5JXTqopt0ZjRV+O2ublCRbPNQWcGh6M63X0PEaXL/BsxkqaWAGscCwa +0nXzG4e8EKXjsTgFpDyTrj+H4iUL1rp5tCA15f9WK/Ls/qff/YGbX6S2d0NdthM iFh5mcN/4wQTDJYb28Lu27RVVO6Fsw4n2AAEbhL3LSLXHsrTPZtUFKrjFuqYrZo= =J76w -----END PGP SIGNATURE-----
