fixed return code on failed connects is wrong #317