I use library http://phpseclib.sourceforge.net/ssh/intro.html.
My script communicates with a remote server via bidirectional xml stream.
It uses the read()
function of the library to read another chunk of data every 30s. In between, my script does something else + sleep()
Now can it be, that my script misses some data, since it "slept" while they came? Is that possible? How else may it miss data incoming via the stream?
If you are referring to sleep() on the PHP (client) side, than it is a question of whether the SSH client is running under your thread or under its own thread.
If its your thread, then yes it can miss data, if its on its own thread, it won't it will be waiting for you to come back.
NOTE: Doing what you are trying to do will be very unstable, some SSH servers will disconnect you after a certain amount of idle time, as well as a connection that doesn't send/recv data is likely to get terminated.
If you're timing out, on the client side, every 30 seconds, it's possible the server times out in less time than that if no packets are read or sent.
What'd be really helpful is the command you're running, the output you're expecting and the output you're getting back. That'll make diagnosing your issues easier.