Sleeptime is now not negative when we use select.

It was still possible that sleeptime was negative when we use select. The only thing that we have to keep in mind, that zero means blocking (when we use select).
I think it should be length instead of msg_length. Or are you referring to another variable? Haven't come across a problem with the old variable, but the reference was to a non existing variable (so it would raise an exception). Haven't tested this solution, but I could only see this variable name which holds a length.