improvement to socket callbacks that alllows for listener exit