start and stop the API socket and thread