socket and cleanup