improved reconnection handling (by giving wait a return value)

Signed-off-by: Bernard `Guyzmo` Pratz <guyzmo+github@m0g.net>