improved reconnection handling (by giving wait a return value)

Signed-off-by: Bernard `Guyzmo` Pratz <guyzmo+github@m0g.net>
added pause/resume support

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