Fix small inefficiency in socketapi