Fix off-by-one error in add_socketread() and set_socketwrite() [Coverity].